1 /***************************************************************************
2 * copyright : (C) 2003-2017 by Pascal Brachet *
3 * addons by Luis Silvestre ; S. Razi Alavizadeh; Robin.Watts *
4 * http://www.xm1math.net/texmaker/ *
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 //#include <stdlib.h>
13
14 #include <QMainWindow>
15 #include <QMenuBar>
16 #include <QToolBar>
17 #include <QAction>
18 #include <QStatusBar>
19 #include <QSettings>
20 #include <QApplication>
21 #include <QDesktopWidget>
22 #include <QTextCodec>
23 #include <QFileInfo>
24 #include <QLabel>
25 #include <QTextStream>
26 #include <QFile>
27 #include <QDir>
28 #include <QMessageBox>
29 #include <QFileDialog>
30 #include <QTreeWidgetItem>
31 #include <QHeaderView>
32 #include <QLineEdit>
33 #include <QProcess>
34 #include <QComboBox>
35 #include <QSpinBox>
36 #include <QTableWidget>
37 #include <QTableWidgetItem>
38 #include <QCheckBox>
39 #include <QLocale>
40 #include <QTabWidget>
41 #include <QStyleFactory>
42 #include <QStyle>
43 #include <QFontDatabase>
44 #include <QTextDocument>
45 #include <QTextCursor>
46 #include <QTextEdit>
47 #include <QTextBlock>
48 #include <QDebug>
49 #include <QDesktopServices>
50 #include <QAbstractItemModel>
51 #include <QTextCharFormat>
52 #include <QTextTableFormat>
53 #include <QTextLength>
54 #include <QFrame>
55 #include <QFontMetrics>
56 #include <QDateTime>
57 #include <QTemporaryFile>
58 #include <QPrintDialog>
59 #include <QPrinter>
60 #include <QProcessEnvironment>
61 #include <QSysInfo>
62
63
64
65
66 //#ifdef Q_WS_WIN
67 //#include <windows.h>
68 //#endif
69
70 #include "geticon.h"
71 #include "texmaker.h"
72 #include "texmakerapp.h"
73 #include "latexeditorview.h"
74 //#include "manhattanstyle.h"
75 #include "structdialog.h"
76 #include "filechooser.h"
77 #include "graphicfilechooser.h"
78 #include "tabdialog.h"
79 #include "arraydialog.h"
80 #include "tabbingdialog.h"
81 #include "letterdialog.h"
82 #include "quickdocumentdialog.h"
83 #include "quickxelatexdialog.h"
84 #include "quickbeamerdialog.h"
85 #include "usermenudialog.h"
86 #include "usertooldialog.h"
87 #include "refdialog.h"
88 #include "configdialog.h"
89 #include "aboutdialog.h"
90 #include "spellerdialog.h"
91 #include "encodingdialog.h"
92 #include "usercompletiondialog.h"
93 #include "texdocdialog.h"
94 #include "addtagdialog.h"
95 #include "exportdialog.h"
96 #include "versiondialog.h"
97 #include "unicodedialog.h"
98 #include "svnhelper.h"
99 #include "theme.h"
100
101 #if defined(Q_OS_UNIX) && !defined(Q_OS_MAC)
102 #include "x11fontdialog.h"
103 #endif
104
105
Texmaker(QWidget * parent)106 Texmaker::Texmaker(QWidget *parent)
107 : QMainWindow(parent)
108 {
109 eraseSettings=false;
110 replaceSettings=false;
111
112 ReadSettings();
113
114
115 QString tempDir=QDir::tempPath();
116 #if defined(Q_OS_UNIX) || defined(Q_OS_MAC)
117 QString path=QStandardPaths::writableLocation(QStandardPaths::CacheLocation);
118 if (QDir().mkpath(path)) tempDir=path;
119 #endif
120 QString prefixFile=QDir::homePath();
121 prefixFile="tks_temp_"+prefixFile.section('/',-1);
122 prefixFile=QString(QUrl::toPercentEncoding(prefixFile));
123 prefixFile.remove("%");
124 sessionTempFile=tempDir+"/"+prefixFile+".tks";
125
126 if (spelldicExist())
127 {
128 QString dic=spell_dic.left(spell_dic.length()-4);
129 spellChecker = new Hunspell(dic.toLatin1()+".aff",dic.toLatin1()+".dic");
130 }
131 else spellChecker=0;
132
133 //spellChecker=0;
134 untitled_id=1;
135
136
137 #if defined(Q_OS_MAC)
138 setWindowIcon(QIcon(":/images/logo128.png"));
139 //MacSupport::addFullscreen(this);
140 #else
141 setWindowIcon(getIcon(":/images/appicon.png"));
142 #endif
143 QApplication::setOrganizationName("Xm1");
144 QApplication::setApplicationName("Texmaker");
145
146 setIconSize(QSize(22,22 ));
147
148 completer = new QCompleter(this);
149 initCompleter();
150
151
152 QAction *Act;
153 splitter1=new MiniSplitter(this);
154 splitter1->setOrientation(Qt::Horizontal);
155 splitter2=new MiniSplitter(splitter1);
156 splitter2->setOrientation(Qt::Vertical);
157 // PANNEAU STRUCTURE
158
159 LeftPanelFrameBis=new QFrame(this);
160 LeftPanelFrameBis->setLineWidth(0);
161 LeftPanelFrameBis->setFrameShape(QFrame::NoFrame);
162 LeftPanelFrameBis->setFrameShadow(QFrame::Plain);
163
164
165
166 LeftPanelToolBarBis=new QToolBar("TitleBar",LeftPanelFrameBis);
167 LeftPanelToolBarBis->setFloatable(false);
168 LeftPanelToolBarBis->setOrientation(Qt::Horizontal);
169 LeftPanelToolBarBis->setMovable(false);
170 LeftPanelToolBarBis->setIconSize(QSize(16,16 ));
171 LeftPanelToolBarBis->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Preferred);
172 LeftPanelToolBarBis->setStyleSheet(Theme::viewportLightStyleSheet);
173
174 QFrame *LeftPanelFrame=new QFrame(this);
175 LeftPanelFrame->setLineWidth(0);
176 LeftPanelFrame->setFrameShape(QFrame::NoFrame);
177 LeftPanelFrame->setFrameShadow(QFrame::Plain);
178
179
180 splitter3=new MiniSplitter(splitter1);
181 splitter3->setOrientation(Qt::Vertical);
182
183 LeftPanelLayout= new QHBoxLayout(LeftPanelFrame);
184 LeftPanelToolBar=new QToolBar("LogToolBar",LeftPanelFrame);
185 LeftPanelToolBar->setFloatable(false);
186 LeftPanelToolBar->setOrientation(Qt::Vertical);
187 LeftPanelToolBar->setMovable(false);
188 LeftPanelToolBar->setIconSize(QSize(16,16 ));
189 LeftPanelToolBar->setStyleSheet(Theme::viewportLightStyleSheet);
190
191
192 LeftPanelStackedWidget=new QStackedWidget(LeftPanelFrame);
193
194
195
196
197 StructureTreeWidget=new QTreeWidget(LeftPanelStackedWidget);
198 StructureTreeWidget->setFrameStyle(QFrame::NoFrame);
199 StructureTreeWidget->setColumnCount(1);
200 StructureTreeWidget->header()->hide();
201 StructureTreeWidget->setEditTriggers(QAbstractItemView::NoEditTriggers);
202 StructureTreeWidget->header()->setHorizontalScrollMode(QAbstractItemView::ScrollPerPixel);
203
204 StructureTreeWidget->header()->setSectionResizeMode(0, QHeaderView::ResizeToContents);
205
206 StructureTreeWidget->header()->setStretchLastSection(false);
207
208 StructureTreeWidget->viewport()->setStyleSheet(Theme::viewportDarkStyleSheet);
209 StructureTreeWidget->setStyleSheet(Theme::treeviewStyleSheet);
210 //StructureTreeWidget->setIndentation(10);
211
212 connect( StructureTreeWidget, SIGNAL(itemClicked(QTreeWidgetItem *,int )), SLOT(ClickedOnStructure(QTreeWidgetItem *,int)));
213
214 connect(LeftPanelToolBar->addAction(getIcon(":/images/structure.png"),tr("Structure")), SIGNAL(triggered()), this, SLOT(ShowStructure()));
215 LeftPanelStackedWidget->addWidget(StructureTreeWidget);
216
217 OpenedFilesListWidget=new QListWidget(LeftPanelFrame);
218 //OpenedFilesListWidget=new QListWidget(LeftPanelStackedWidget);
219 OpenedFilesListWidget->setFrameStyle(QFrame::NoFrame);
220 connect(OpenedFilesListWidget, SIGNAL(itemClicked ( QListWidgetItem*)), this, SLOT(OpenedFileActivated(QListWidgetItem*)));
221 OpenedFilesListWidget->viewport()->setStyleSheet(Theme::viewportDarkStyleSheet);
222 OpenedFilesListWidget->setStyleSheet(Theme::listwidgetStyleSheet);
223 //connect(LeftPanelToolBar->addAction(QIcon(":/images/opened.png"),tr("Opened Files")), SIGNAL(triggered()), this, SLOT(ShowOpenedFiles()));
224 //LeftPanelStackedWidget->addWidget(OpenedFilesListWidget);
225
226
227 LeftPanelToolBar->addSeparator();
228
229
230 RelationListWidget=new SymbolListWidget(LeftPanelStackedWidget,0);
231 RelationListWidget->setFrameStyle(QFrame::NoFrame);
232 connect(RelationListWidget, SIGNAL(itemClicked ( QTableWidgetItem*)), this, SLOT(InsertSymbol(QTableWidgetItem*)));
233 relationAct = new QAction(getIcon(":/images/math1.png"),tr("Relation symbols"), this);
234 connect(relationAct, SIGNAL(triggered()), this, SLOT(ShowRelation()));
235 LeftPanelToolBar->addAction(relationAct);
236 connect(RelationListWidget->addAct, SIGNAL(triggered()), this, SLOT(InsertFavoriteSymbols()));
237 LeftPanelStackedWidget->addWidget(RelationListWidget);
238
239
240 ArrowListWidget=new SymbolListWidget(LeftPanelStackedWidget,1);
241 ArrowListWidget->setFrameStyle(QFrame::NoFrame);
242 connect(ArrowListWidget, SIGNAL(itemClicked ( QTableWidgetItem*)), this, SLOT(InsertSymbol(QTableWidgetItem*)));
243 arrowAct = new QAction(getIcon(":/images/math2.png"),tr("Arrow symbols"), this);
244 connect(arrowAct, SIGNAL(triggered()), this, SLOT(ShowArrow()));
245 LeftPanelToolBar->addAction(arrowAct);
246 connect(ArrowListWidget->addAct, SIGNAL(triggered()), this, SLOT(InsertFavoriteSymbols()));
247 LeftPanelStackedWidget->addWidget(ArrowListWidget);
248
249 MiscellaneousListWidget=new SymbolListWidget(LeftPanelStackedWidget,2);
250 MiscellaneousListWidget->setFrameStyle(QFrame::NoFrame);
251 connect(MiscellaneousListWidget, SIGNAL(itemClicked ( QTableWidgetItem*)), this, SLOT(InsertSymbol(QTableWidgetItem*)));
252 miscAct = new QAction(getIcon(":/images/math3.png"),tr("Miscellaneous symbols"), this);
253 connect(miscAct, SIGNAL(triggered()), this, SLOT(ShowMisc()));
254 LeftPanelToolBar->addAction(miscAct);
255 connect(MiscellaneousListWidget->addAct, SIGNAL(triggered()), this, SLOT(InsertFavoriteSymbols()));
256 LeftPanelStackedWidget->addWidget(MiscellaneousListWidget);
257
258 DelimitersListWidget=new SymbolListWidget(LeftPanelStackedWidget,3);
259 DelimitersListWidget->setFrameStyle(QFrame::NoFrame);
260 connect(DelimitersListWidget, SIGNAL(itemClicked ( QTableWidgetItem*)), this, SLOT(InsertSymbol(QTableWidgetItem*)));
261 delimAct = new QAction(getIcon(":/images/math4.png"),tr("Delimiters"), this);
262 connect(delimAct, SIGNAL(triggered()), this, SLOT(ShowDelim()));
263 LeftPanelToolBar->addAction(delimAct);
264 connect(DelimitersListWidget->addAct, SIGNAL(triggered()), this, SLOT(InsertFavoriteSymbols()));
265 LeftPanelStackedWidget->addWidget(DelimitersListWidget);
266
267 GreekListWidget=new SymbolListWidget(LeftPanelStackedWidget,4);
268 GreekListWidget->setFrameStyle(QFrame::NoFrame);
269 connect(GreekListWidget, SIGNAL(itemClicked ( QTableWidgetItem*)), this, SLOT(InsertSymbol(QTableWidgetItem*)));
270 greekAct = new QAction(getIcon(":/images/math5.png"),tr("Greek letters"), this);
271 connect(greekAct, SIGNAL(triggered()), this, SLOT(ShowGreek()));
272 LeftPanelToolBar->addAction(greekAct);
273 connect(GreekListWidget->addAct, SIGNAL(triggered()), this, SLOT(InsertFavoriteSymbols()));
274 LeftPanelStackedWidget->addWidget(GreekListWidget);
275
276 MostUsedListWidget=new SymbolListWidget(LeftPanelStackedWidget,5);
277 MostUsedListWidget->setFrameStyle(QFrame::NoFrame);
278 connect(MostUsedListWidget, SIGNAL(itemClicked ( QTableWidgetItem*)), this, SLOT(InsertSymbol(QTableWidgetItem*)));
279 usedAct = new QAction(getIcon(":/images/math6.png"),tr("Most used symbols"), this);
280 connect(usedAct, SIGNAL(triggered()), this, SLOT(ShowMostUsed()));
281 LeftPanelToolBar->addAction(usedAct);
282 SetMostUsedSymbols();
283 LeftPanelStackedWidget->addWidget(MostUsedListWidget);
284
285 FavoriteListWidget=new SymbolListWidget(LeftPanelStackedWidget,6);
286 FavoriteListWidget->setFrameStyle(QFrame::NoFrame);
287 connect(FavoriteListWidget, SIGNAL(itemClicked ( QTableWidgetItem*)), this, SLOT(InsertSymbol(QTableWidgetItem*)));
288 favAct = new QAction(getIcon(":/images/math7.png"),tr("Favorites symbols"), this);
289 connect(favAct, SIGNAL(triggered()), this, SLOT(ShowFavorite()));
290 LeftPanelToolBar->addAction(favAct);
291 FavoriteListWidget->SetFavoritePage(favoriteSymbolList);
292 connect(FavoriteListWidget->remAct, SIGNAL(triggered()), this, SLOT(RemoveFavoriteSymbols()));
293 LeftPanelStackedWidget->addWidget(FavoriteListWidget);
294
295 LeftPanelToolBar->addSeparator();
296
297
298 leftrightWidget=new XmlTagsListWidget(LeftPanelStackedWidget,":/tags/leftright_tags.xml");
299 leftrightWidget->setFrameStyle(QFrame::NoFrame);
300 connect(leftrightWidget, SIGNAL(itemClicked ( QListWidgetItem*)), this, SLOT(InsertXmlTag(QListWidgetItem*)));
301 leftrightAct = new QAction(getIcon(":/images/leftright.png"),"left/right", this);
302 connect(leftrightAct, SIGNAL(triggered()), this, SLOT(ShowLeftRight()));
303 LeftPanelToolBar->addAction(leftrightAct);
304 LeftPanelStackedWidget->addWidget(leftrightWidget);
305
306 LeftPanelToolBar->addSeparator();
307
308 usertagsListWidget=new UserTagsListWidget(LeftPanelStackedWidget);
309 usertagsListWidget->setFrameStyle(QFrame::NoFrame);
310 connect(usertagsListWidget, SIGNAL(itemClicked ( QListWidgetItem*)), this, SLOT(InsertUserElement(QListWidgetItem*)));
311 userpanelAct = new QAction(getIcon(":/images/user.png"),tr("User"), this);
312 connect(userpanelAct, SIGNAL(triggered()), this, SLOT(ShowUserPanel()));
313 LeftPanelToolBar->addAction(userpanelAct);
314 usertagsListWidget->updateList(userTagsList);
315 connect(usertagsListWidget->remAct, SIGNAL(triggered()), this, SLOT(RemoveUserTag()));
316 connect(usertagsListWidget->addAct, SIGNAL(triggered()), this, SLOT(AddUserTag()));
317 connect(usertagsListWidget->changeAct, SIGNAL(triggered()), this, SLOT(ChangeUserTag()));
318 connect(usertagsListWidget, SIGNAL(posChanged()), this, SLOT(UpdateUserTag()));
319
320 LeftPanelStackedWidget->addWidget(usertagsListWidget);
321
322 LeftPanelToolBar->addSeparator();
323
324 PsListWidget=new XmlTagsListWidget(LeftPanelStackedWidget,":/tags/pstricks_tags.xml");
325 PsListWidget->setFrameStyle(QFrame::NoFrame);
326 connect(PsListWidget, SIGNAL(itemClicked ( QListWidgetItem*)), this, SLOT(InsertXmlTag(QListWidgetItem*)));
327 pstricksAct = new QAction(getIcon(":/images/pstricks.png"),tr("Pstricks Commands"), this);
328 connect(pstricksAct, SIGNAL(triggered()), this, SLOT(ShowPstricks()));
329 if (showPstricks) LeftPanelToolBar->addAction(pstricksAct);
330 LeftPanelStackedWidget->addWidget(PsListWidget);
331
332 MpListWidget=new XmlTagsListWidget(LeftPanelStackedWidget,":/tags/metapost_tags.xml");
333 MpListWidget->setFrameStyle(QFrame::NoFrame);
334 connect(MpListWidget, SIGNAL(itemClicked ( QListWidgetItem*)), this, SLOT(InsertXmlTag(QListWidgetItem*)));
335 mpAct = new QAction(getIcon(":/images/metapost.png"),tr("MetaPost Commands"), this);
336 connect(mpAct, SIGNAL(triggered()), this, SLOT(ShowMplist()));
337 if (showMp) LeftPanelToolBar->addAction(mpAct);
338 LeftPanelStackedWidget->addWidget(MpListWidget);
339
340 tikzWidget=new XmlTagsListWidget(LeftPanelStackedWidget,":/tags/tikz_tags.xml");
341 tikzWidget->setFrameStyle(QFrame::NoFrame);
342 connect(tikzWidget, SIGNAL(itemClicked ( QListWidgetItem*)), this, SLOT(InsertXmlTag(QListWidgetItem*)));
343 tikzAct = new QAction(getIcon(":/images/tikz.png"),tr("Tikz Commands"), this);
344 connect(tikzAct, SIGNAL(triggered()), this, SLOT(ShowTikz()));
345 if (showTikz) LeftPanelToolBar->addAction(tikzAct);
346 LeftPanelStackedWidget->addWidget(tikzWidget);
347
348 asyWidget=new XmlTagsListWidget(LeftPanelStackedWidget,":/tags/asymptote_tags.xml");
349 asyWidget->setFrameStyle(QFrame::NoFrame);
350 connect(asyWidget, SIGNAL(itemClicked ( QListWidgetItem*)), this, SLOT(InsertXmlTag(QListWidgetItem*)));
351 asyAct = new QAction(getIcon(":/images/asymptote.png"),tr("Asymptote Commands"), this);
352 connect(asyAct, SIGNAL(triggered()), this, SLOT(ShowAsy()));
353 if (showAsy) LeftPanelToolBar->addAction(asyAct);
354 LeftPanelStackedWidget->addWidget(asyWidget);
355
356
357
358
359
360 viewPstricksAct = new QAction(tr("Pstricks Commands"), this);
361 viewPstricksAct->setCheckable(true);
362 connect(viewPstricksAct, SIGNAL(triggered()), this, SLOT(TogglePstricks()));
363 viewMpAct = new QAction(tr("MetaPost Commands"), this);
364 viewMpAct->setCheckable(true);
365 connect(viewMpAct, SIGNAL(triggered()), this, SLOT(ToggleMetapost()));
366 viewTikzAct = new QAction(tr("Tikz Commands"), this);
367 viewTikzAct->setCheckable(true);
368 connect(viewTikzAct, SIGNAL(triggered()), this, SLOT(ToggleTikz()));
369 viewAsyAct = new QAction(tr("Asymptote Commands"), this);
370 viewAsyAct->setCheckable(true);
371 connect(viewAsyAct, SIGNAL(triggered()), this, SLOT(ToggleAsymptote()));
372 LeftPanelToolBar->setContextMenuPolicy(Qt::CustomContextMenu);
373 connect(LeftPanelToolBar, SIGNAL( customContextMenuRequested( const QPoint & )), this, SLOT( customContentsMenuStructure( const QPoint & )));
374
375 LeftPanelLayout->setSpacing(0);
376 LeftPanelLayout->setMargin(0);
377 LeftPanelLayout->addWidget(LeftPanelToolBar);
378 LeftPanelLayout->addWidget(LeftPanelStackedWidget);
379
380 LeftPanelStackedWidget->setCurrentWidget(StructureTreeWidget);
381 //Act = new QAction(QIcon(":/images/empty.png"),"", this);
382 //LeftPanelToolBarBis->addAction(Act);
383 //Act->setEnabled(false);
384 titleLeftPanel=new DropShadowLabel(tr("Structure").toUpper(),LeftPanelToolBarBis);
385 titleLeftPanel->setColor(Theme::grayColor);
386 titleLeftPanel->setDropShadowColor(QColor("#000000"));
387 titleLeftPanel->setStyleSheet(Theme::labelStyleSheet);
388 LeftPanelToolBarBis->addWidget(titleLeftPanel);
389
390 LeftPanelLayoutBis= new QVBoxLayout(LeftPanelFrameBis);
391 LeftPanelLayoutBis->setSpacing(0);
392 LeftPanelLayoutBis->setMargin(0);
393 LeftPanelLayoutBis->addWidget(LeftPanelToolBarBis);
394 LeftPanelLayoutBis->addWidget(LeftPanelFrame);
395
396 splitter3->addWidget(LeftPanelFrameBis);
397 splitter3->addWidget(OpenedFilesListWidget);
398
399 splitter1->addWidget(splitter3);
400 splitter3->setMinimumWidth(210);
401
402 Outputframe=new QFrame(this);
403 Outputframe->setLineWidth(0);
404 Outputframe->setFrameShape(QFrame::NoFrame);
405 Outputframe->setFrameShadow(QFrame::Plain);
406
407 OutputLayoutH= new QHBoxLayout(Outputframe);
408 OutputLayoutH->setSpacing(0);
409 OutputLayoutH->setMargin(0);
410
411 logToolBar=new QToolBar("LogToolBar",Outputframe);
412 logToolBar->setFloatable(false);
413 logToolBar->setOrientation(Qt::Vertical);
414 logToolBar->setMovable(false);
415 logToolBar->setIconSize(QSize(16,16 ));
416 logToolBar->setStyleSheet(Theme::viewportLightStyleSheet);
417
418 QFrame *Outputframebis=new QFrame(this);
419 Outputframebis->setLineWidth(0);
420 Outputframebis->setFrameShape(QFrame::NoFrame);
421 Outputframebis->setFrameShadow(QFrame::Plain);
422
423 OutputLayoutV= new QVBoxLayout(Outputframebis);
424 OutputLayoutV->setSpacing(0);
425 OutputLayoutV->setMargin(0);
426
427 OutputTableWidget= new QTableWidget (1,5,Outputframebis);
428 //OutputTableWidget->setFrameShape(QFrame::Box);
429 OutputTableWidget->setFrameShadow(QFrame::Plain);
430 OutputTableWidget->setFrameStyle(QFrame::NoFrame);
431 QTableWidgetItem *HeaderItem = new QTableWidgetItem(" ");
432 HeaderItem->setTextAlignment(Qt::AlignLeft);
433 OutputTableWidget->setHorizontalHeaderItem(0,HeaderItem);
434 HeaderItem = new QTableWidgetItem("File");
435 HeaderItem->setTextAlignment(Qt::AlignLeft);
436 OutputTableWidget->setHorizontalHeaderItem(1,HeaderItem);
437 HeaderItem = new QTableWidgetItem("Type");
438 HeaderItem->setTextAlignment(Qt::AlignLeft);
439 OutputTableWidget->setHorizontalHeaderItem(2,HeaderItem);
440 HeaderItem = new QTableWidgetItem("Line");
441 HeaderItem->setTextAlignment(Qt::AlignLeft);
442 OutputTableWidget->setHorizontalHeaderItem(3,HeaderItem);
443 HeaderItem = new QTableWidgetItem("Message");
444 HeaderItem->setTextAlignment(Qt::AlignLeft);
445 OutputTableWidget->setHorizontalHeaderItem(4,HeaderItem);
446
447 //OutputTableWidget->setWordWrap(true);
448 OutputTableWidget->setSelectionMode (QAbstractItemView::SingleSelection);
449 QFontMetrics fm(qApp->font());
450 OutputTableWidget->setColumnWidth(0,fm.width("> "));
451 OutputTableWidget->setColumnWidth(1,10*fm.width("w"));
452 OutputTableWidget->setColumnWidth(2,fm.width("WarningWW"));
453 OutputTableWidget->setColumnWidth(3,fm.width("Line WWWWWWWW"));
454 OutputTableWidget->setColumnWidth(4,20*fm.width("w"));
455 connect(OutputTableWidget, SIGNAL(itemClicked ( QTableWidgetItem*)), this, SLOT(ClickedOnLogLine(QTableWidgetItem*)));
456 OutputTableWidget->horizontalHeader()->setStretchLastSection(true);
457 OutputTableWidget->setMinimumHeight(4*(fm.lineSpacing()+4));
458 //OutputTableWidget->setMaximumHeight(8*(fm.lineSpacing()+4));
459 OutputTableWidget->verticalHeader()->hide();
460 //OutputTableWidget->horizontalHeader()->hide();
461
462
463
464
465 OutputTextEdit = new LogEditor(Outputframebis);
466 OutputTextEdit->setFrameStyle(QFrame::NoFrame);
467 OutputTextEdit->setMinimumHeight(4*(fm.lineSpacing()+4));
468 connect(OutputTextEdit, SIGNAL(clickonline(int )),this,SLOT(ClickedOnOutput(int )));
469
470 separatorline = new QFrame(Outputframebis);
471 separatorline->setMinimumHeight(1);
472 separatorline->setMaximumHeight(1);
473 separatorline->setFrameShape(QFrame::Box);
474 separatorline->setFrameShadow(QFrame::Plain);
475 separatorline->setStyleSheet("color:black");
476
477
478 OutputLayoutV->addWidget(OutputTableWidget);
479 OutputLayoutV->addWidget(separatorline);
480 OutputLayoutV->addWidget(OutputTextEdit);
481 OutputLayoutH->addWidget(logToolBar);
482 OutputLayoutH->addWidget(Outputframebis);
483 OutputLayoutH->setSpacing(0);
484
485 OutputTableWidget->hide();
486 separatorline->hide();
487
488
489 logpresent=false;
490 listViewerCommands.clear();
491 checkViewerInstance=false;
492
493 errorFileList.clear();
494 errorTypeList.clear();
495 errorLineList.clear();
496 errorMessageList.clear();
497 errorLogList.clear();
498 onlyErrorList.clear();
499 errorIndex=-1;
500
501 translationList.clear();
502 translationList.append(QString("en"));
503
504 #if defined(Q_OS_UNIX) && !defined(Q_OS_MAC)
505 #ifdef USB_VERSION
506 QDir transdir(QCoreApplication::applicationDirPath());
507 #else
508 QDir transdir(PREFIX"/share/texmaker");
509 #endif
510
511 #endif
512 #if defined(Q_OS_MAC)
513 QDir transdir(QCoreApplication::applicationDirPath() + "/../Resources");
514 #endif
515 #if defined(Q_OS_WIN32)
516 QDir transdir(QCoreApplication::applicationDirPath());
517 #endif
518 foreach (QFileInfo qmFileInfo, transdir.entryInfoList(QStringList("texmaker_*.qm"),QDir::Files | QDir::Readable, QDir::Name | QDir::IgnoreCase))
519 {
520 QString transName = qmFileInfo.completeBaseName();
521 transName.remove("texmaker_");
522 translationList.append(transName);
523 }
524
525 scriptList.clear();
526 foreach (QFileInfo qmScriptInfo, transdir.entryInfoList(QStringList("*.tms"),QDir::Files | QDir::Readable, QDir::Name | QDir::IgnoreCase))
527 {
528 scriptList.append(qmScriptInfo.completeBaseName());
529 }
530
531
532 StackedViewers=new QStackedWidget(this);
533 StackedViewers->setLineWidth(0);
534 StackedViewers->setFrameShape(QFrame::NoFrame);
535 StackedViewers->setFrameShadow(QFrame::Plain);
536 StackedViewers->setMinimumWidth(200);
537
538
539 // EDITEUR
540 QFrame *centralFrame=new QFrame(this);
541 centralFrame->setLineWidth(0);
542 centralFrame->setFrameShape(QFrame::NoFrame);
543 centralFrame->setFrameShadow(QFrame::Plain);
544
545
546 centralToolBar=new QToolBar("LogToolBar",centralFrame);
547 centralToolBar->setFloatable(false);
548 centralToolBar->setOrientation(Qt::Vertical);
549 centralToolBar->setMovable(false);
550 centralToolBar->setIconSize(QSize(16,16 ));
551 centralToolBar->setStyleSheet(Theme::viewportLightStyleSheet);
552
553
554 sectionMenu=new QMenu(this);
555 Act = new QAction("part", this);
556 connect(Act, SIGNAL(triggered()), this, SLOT(SectionCommand()));
557 sectionMenu->addAction(Act);
558 Act = new QAction("chapter", this);
559 connect(Act, SIGNAL(triggered()), this, SLOT(SectionCommand()));
560 sectionMenu->addAction(Act);
561 Act = new QAction("section", this);
562 connect(Act, SIGNAL(triggered()), this, SLOT(SectionCommand()));
563 sectionMenu->addAction(Act);
564 Act = new QAction("subsection", this);
565 connect(Act, SIGNAL(triggered()), this, SLOT(SectionCommand()));
566 sectionMenu->addAction(Act);
567 Act = new QAction("subsubsection", this);
568 connect(Act, SIGNAL(triggered()), this, SLOT(SectionCommand()));
569 sectionMenu->addAction(Act);
570 Act = new QAction("paragraph", this);
571 connect(Act, SIGNAL(triggered()), this, SLOT(SectionCommand()));
572 sectionMenu->addAction(Act);
573 Act = new QAction("subparagraph", this);
574 connect(Act, SIGNAL(triggered()), this, SLOT(SectionCommand()));
575 sectionMenu->addAction(Act);
576
577 refMenu=new QMenu(this);
578 Act = new QAction("label", this);
579 connect(Act, SIGNAL(triggered()), this, SLOT(OtherCommand()));
580 refMenu->addAction(Act);
581 Act = new QAction("ref", this);
582 connect(Act, SIGNAL(triggered()), this, SLOT(OtherCommand()));
583 refMenu->addAction(Act);
584 Act = new QAction("pageref", this);
585 connect(Act, SIGNAL(triggered()), this, SLOT(OtherCommand()));
586 refMenu->addAction(Act);
587 Act = new QAction("index", this);
588 connect(Act, SIGNAL(triggered()), this, SLOT(OtherCommand()));
589 refMenu->addAction(Act);
590 Act = new QAction("cite", this);
591 connect(Act, SIGNAL(triggered()), this, SLOT(OtherCommand()));
592 refMenu->addAction(Act);
593 Act = new QAction("footnote", this);
594 connect(Act, SIGNAL(triggered()), this, SLOT(OtherCommand()));
595 refMenu->addAction(Act);
596
597 sizeMenu=new QMenu(this);
598 Act = new QAction("tiny", this);
599 connect(Act, SIGNAL(triggered()), this, SLOT(SizeCommand()));
600 sizeMenu->addAction(Act);
601 Act = new QAction("scriptsize", this);
602 connect(Act, SIGNAL(triggered()), this, SLOT(SizeCommand()));
603 sizeMenu->addAction(Act);
604 Act = new QAction("footnotesize", this);
605 connect(Act, SIGNAL(triggered()), this, SLOT(SizeCommand()));
606 sizeMenu->addAction(Act);
607 Act = new QAction("small", this);
608 connect(Act, SIGNAL(triggered()), this, SLOT(SizeCommand()));
609 sizeMenu->addAction(Act);
610 Act = new QAction("normalsize", this);
611 connect(Act, SIGNAL(triggered()), this, SLOT(SizeCommand()));
612 sizeMenu->addAction(Act);
613 Act = new QAction("large", this);
614 connect(Act, SIGNAL(triggered()), this, SLOT(SizeCommand()));
615 sizeMenu->addAction(Act);
616 Act = new QAction("Large", this);
617 connect(Act, SIGNAL(triggered()), this, SLOT(SizeCommand()));
618 sizeMenu->addAction(Act);
619 Act = new QAction("LARGE", this);
620 connect(Act, SIGNAL(triggered()), this, SLOT(SizeCommand()));
621 sizeMenu->addAction(Act);
622 Act = new QAction("huge", this);
623 connect(Act, SIGNAL(triggered()), this, SLOT(SizeCommand()));
624 sizeMenu->addAction(Act);
625 Act = new QAction("Huge", this);
626 connect(Act, SIGNAL(triggered()), this, SLOT(SizeCommand()));
627 sizeMenu->addAction(Act);
628
629 Act = new QAction(getIcon(":/images/sectioning.png"),"part/chapter/section...", this);
630 connect(Act, SIGNAL(triggered()), this, SLOT(ShowSectionMenu()));
631 centralToolBar->addAction(Act);
632 Act = new QAction(getIcon(":/images/ref.png"),"Label/ref/cite...", this);
633 connect(Act, SIGNAL(triggered()), this, SLOT(ShowRefMenu()));
634 centralToolBar->addAction(Act);
635 Act = new QAction(getIcon(":/images/size.png"),"tiny/small/large...", this);
636 connect(Act, SIGNAL(triggered()), this, SLOT(ShowSizeMenu()));
637 centralToolBar->addAction(Act);
638
639 centralToolBar->addSeparator();
640
641 Act = new QAction(getIcon(":/images/text_bold.png"),tr("Bold"), this);
642 Act->setData("\\textbf{/}/8/0");
643 connect(Act, SIGNAL(triggered()), this, SLOT(InsertWithSelectionFromAction()));
644 centralToolBar->addAction(Act);
645
646 Act = new QAction(getIcon(":/images/text_italic.png"),tr("Italic"), this);
647 Act->setData("\\textit{/}/8/0");
648 connect(Act, SIGNAL(triggered()), this, SLOT(InsertWithSelectionFromAction()));
649 centralToolBar->addAction(Act);
650
651 emphasisAct = new QAction(getIcon(":/images/text_emphasis.png"),"Emphasis", this);
652 emphasisAct->setData("\\emph{/}/6/0");
653 connect(emphasisAct, SIGNAL(triggered()), this, SLOT(InsertWithSelectionFromAction()));
654 if (showEmphasis) centralToolBar->addAction(emphasisAct);
655
656 Act = new QAction(getIcon(":/images/text_left.png"),tr("Left"), this);
657 Act->setData("\\begin{flushleft}\n/\n\\end{flushleft}/0/1");
658 connect(Act, SIGNAL(triggered()), this, SLOT(InsertWithSelectionFromAction()));
659 centralToolBar->addAction(Act);
660
661 Act = new QAction(getIcon(":/images/text_center.png"),tr("Center"), this);
662 Act->setData("\\begin{center}\n/\n\\end{center}/0/1");
663 connect(Act, SIGNAL(triggered()), this, SLOT(InsertWithSelectionFromAction()));
664 centralToolBar->addAction(Act);
665
666 Act = new QAction(getIcon(":/images/text_right.png"),tr("Right"), this);
667 Act->setData("\\begin{flushright}\n/\n\\end{flushright}/0/1");
668 connect(Act, SIGNAL(triggered()), this, SLOT(InsertWithSelectionFromAction()));
669 centralToolBar->addAction(Act);
670 centralToolBar->addSeparator();
671
672 newlineAct = new QAction(getIcon(":/images/newline.png"),tr("New line"), this);
673 newlineAct->setData("\\\\\n/0/1/The \\newline command breaks the line right where it is. It can only be used in paragraph mode.");
674 connect(newlineAct, SIGNAL(triggered()), this, SLOT(InsertFromAction()));
675 if (showNewline) centralToolBar->addAction(newlineAct);
676
677 centralToolBar->addSeparator();
678
679 mathmodeAct = new QAction(getIcon(":/images/mathmode.png"),"$...$", this);
680 mathmodeAct->setData("$ $/2/0/The math environment can be used in both paragraph and LR mode");
681 connect(mathmodeAct, SIGNAL(triggered()), this, SLOT(InsertFromAction()));
682 if (showMathmode) centralToolBar->addAction(mathmodeAct);
683
684 indiceAct = new QAction(getIcon(":/images/indice.png"),"_{} - subscript", this);
685 indiceAct->setData("_{}/2/0/ ");
686 connect(indiceAct, SIGNAL(triggered()), this, SLOT(InsertFromAction()));
687 if (showIndice) centralToolBar->addAction(indiceAct);
688
689 puissanceAct = new QAction(getIcon(":/images/puissance.png"),"^{} - superscript", this);
690 puissanceAct->setData("^{}/2/0/ ");
691 connect(puissanceAct, SIGNAL(triggered()), this, SLOT(InsertFromAction()));
692 if (showPuissance) centralToolBar->addAction(puissanceAct);
693
694 smallfracAct = new QAction(getIcon(":/images/smallfrac.png"),"\\frac{}{}", this);
695 smallfracAct->setData("\\frac{}{}/6/0/ ");
696 connect(smallfracAct, SIGNAL(triggered()), this, SLOT(InsertFromAction()));
697 if (showSmallfrac) centralToolBar->addAction(smallfracAct);
698
699 dfracAct = new QAction(getIcon(":/images/dfrac.png"),"\\dfrac{}{}", this);
700 dfracAct->setData("\\dfrac{}{}/7/0/ ");
701 connect(dfracAct, SIGNAL(triggered()), this, SLOT(InsertFromAction()));
702 if (showDfrac) centralToolBar->addAction(dfracAct);
703
704 racineAct = new QAction(getIcon(":/images/racine.png"),"\\sqrt{}", this);
705 racineAct->setData("\\sqrt{}/6/0/ ");
706 connect(racineAct, SIGNAL(triggered()), this, SLOT(InsertFromAction()));
707 if (showRacine) centralToolBar->addAction(racineAct);
708
709 showemphasisAct = new QAction("Emphasis", this);
710 showemphasisAct->setCheckable(true);
711 connect(showemphasisAct, SIGNAL(triggered()), this, SLOT(ToggleEmphasis()));
712 shownewlineAct = new QAction(tr("New line"), this);
713 shownewlineAct->setCheckable(true);
714 connect(shownewlineAct, SIGNAL(triggered()), this, SLOT(ToggleNewline()));
715 showmathmodeAct = new QAction("$...$", this);
716 showmathmodeAct->setCheckable(true);
717 connect(showmathmodeAct, SIGNAL(triggered()), this, SLOT(ToggleMathmode()));
718 showindiceAct = new QAction("_{} - subscript", this);
719 showindiceAct->setCheckable(true);
720 connect(showindiceAct, SIGNAL(triggered()), this, SLOT(ToggleIndice()));
721 showpuissanceAct = new QAction("^{} - superscript", this);
722 showpuissanceAct->setCheckable(true);
723 connect(showpuissanceAct, SIGNAL(triggered()), this, SLOT(TogglePuissance()));
724 showsmallfracAct = new QAction("\\frac{}{}", this);
725 showsmallfracAct->setCheckable(true);
726 connect(showsmallfracAct, SIGNAL(triggered()), this, SLOT(ToggleSmallfrac()));
727 showdfracAct = new QAction("\\dfrac{}{}", this);
728 showdfracAct->setCheckable(true);
729 connect(showdfracAct, SIGNAL(triggered()), this, SLOT(ToggleDfrac()));
730 showracineAct = new QAction("\\sqrt{}", this);
731 showracineAct->setCheckable(true);
732 connect(showracineAct, SIGNAL(triggered()), this, SLOT(ToggleRacine()));
733 centralToolBar->setContextMenuPolicy(Qt::CustomContextMenu);
734 connect(centralToolBar, SIGNAL( customContextMenuRequested( const QPoint & )), this, SLOT( customContentsMenuMain( const QPoint & )));
735
736 QFrame *centralFrameBis=new QFrame(this);
737 centralFrameBis->setLineWidth(0);
738 centralFrameBis->setFrameShape(QFrame::NoFrame);
739 centralFrameBis->setFrameShadow(QFrame::Plain);
740
741 centralToolBarBis=new QToolBar("FileBar",centralFrameBis);
742 centralToolBarBis->setFloatable(false);
743 centralToolBarBis->setOrientation(Qt::Horizontal);
744 centralToolBarBis->setMovable(false);
745 centralToolBarBis->setIconSize(QSize(16,16 ));
746 centralToolBarBis->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Minimum);
747 centralToolBarBis->setStyleSheet(Theme::viewportLightStyleSheet);
748
749 //LeftPanelToolBarBis->setMinimumHeight(centralToolBarBis->height());
750 //LeftPanelToolBarBis->setMaximumHeight(centralToolBarBis->height());
751 //centralToolBarBis->setStyle(QStyleFactory::create("Plastique"));
752
753 ToggleDocAct=new QAction(getIcon(":/images/toggle.png"),tr("Toggle between the master document and the current document")+" (CTRL+SHIFT+F2)", this);
754 ToggleDocAct->setShortcut(Qt::CTRL+Qt::SHIFT+Qt::Key_F2);
755 connect(ToggleDocAct, SIGNAL(triggered()), this, SLOT(ToggleMasterCurrent()));
756 centralToolBarBis->addAction(ToggleDocAct);
757
758 Act = new QAction(getIcon(":/images/errorprev.png"),tr("Previous Document"), this);
759 //Act->setShortcut(Qt::ALT+Qt::Key_PageUp);
760 connect(Act, SIGNAL(triggered()), this, SLOT(gotoPrevDocument()));
761 centralToolBarBis->addAction(Act);
762 Act = new QAction(getIcon(":/images/errornext.png"),tr("Next Document"), this);
763 //Act->setShortcut(Qt::ALT+Qt::Key_PageDown);
764 connect(Act, SIGNAL(triggered()), this, SLOT(gotoNextDocument()));
765 centralToolBarBis->addAction(Act);
766
767
768 comboFiles=new QComboBox(centralToolBarBis);
769 comboFiles->setMaximumWidth(300);
770 comboFiles->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Minimum);
771 comboFiles->setMinimumContentsLength(20);
772 comboFiles->setMaxVisibleItems(40);
773 comboFiles->setContextMenuPolicy(Qt::CustomContextMenu);
774 comboFiles->setStyleSheet(Theme::comboboxLightStyleSheet);
775 connect(comboFiles, SIGNAL(activated(int)), this, SLOT(listSelectionActivated(int)));
776 centralToolBarBis->addWidget(comboFiles);
777 QWidget* spacer = new QWidget();
778 spacer->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
779 centralToolBarBis->addWidget(spacer);
780 Act = new QAction(getIcon(":/images/fileclose.png"), tr("Close"), this);
781 connect(Act, SIGNAL(triggered()), this, SLOT(fileClose()));
782 centralToolBarBis->addAction(Act);
783 centralToolBarBis->addSeparator();
784
785 posLabel=new DropShadowLabel("L: C: ",centralToolBarBis);
786 posLabel->setFixedWidth(fm.width("L:99999 C:99999"));
787 posLabel->setColor(Theme::grayColor);
788 posLabel->setDropShadowColor(QColor("#000000"));
789 posLabel->setStyleSheet(Theme::labelStyleSheet);
790
791 //posLabel=new QLabel("L: C: ",centralToolBarBis);
792 //posLabel->setFixedWidth(fm.width("L:99999 C:99999"));
793 centralToolBarBis->addWidget(posLabel);
794 centralToolBarBis->addSeparator();
795 Act = new QAction(getIcon(":/images/bookmark1.png"),tr("Click to jump to the bookmark"), this);
796 connect(Act, SIGNAL(triggered()), this, SLOT(gotoBookmark1()));
797 centralToolBarBis->addAction(Act);
798 Act = new QAction(getIcon(":/images/bookmark2.png"),tr("Click to jump to the bookmark"), this);
799 connect(Act, SIGNAL(triggered()), this, SLOT(gotoBookmark2()));
800 centralToolBarBis->addAction(Act);
801 Act = new QAction(getIcon(":/images/bookmark3.png"),tr("Click to jump to the bookmark"), this);
802 connect(Act, SIGNAL(triggered()), this, SLOT(gotoBookmark3()));
803 centralToolBarBis->addAction(Act);
804
805 EditorView=new QStackedWidget(centralFrame);
806 EditorView->setLineWidth(0);
807 EditorView->setFrameShape(QFrame::NoFrame);
808 EditorView->setFrameShadow(QFrame::Plain);
809
810 connect(EditorView, SIGNAL( currentChanged( int ) ), this, SLOT(UpdateCaption()) );
811 connect(EditorView, SIGNAL( currentChanged( int ) ), this, SLOT(UpdateStructure()) );
812
813 CentralLayout= new QHBoxLayout(centralFrame);
814 CentralLayout->setSpacing(0);
815 CentralLayout->setMargin(0);
816 CentralLayout->addWidget(centralToolBar);
817 CentralLayout->addWidget(EditorView);
818
819 CentralLayoutBis= new QVBoxLayout(centralFrameBis);
820 CentralLayoutBis->setSpacing(0);
821 CentralLayoutBis->setMargin(0);
822 CentralLayoutBis->addWidget(centralToolBarBis);
823 CentralLayoutBis->addWidget(centralFrame);
824
825
826 splitter2->addWidget(centralFrameBis);
827 splitter2->addWidget(Outputframe);
828 connect(splitter2,SIGNAL(splitterMoved(int,int)), this, SLOT(splitter2Changed()));
829 //splitter1->addWidget(splitter3);
830 splitter1->addWidget(splitter2);
831 splitter1->addWidget(StackedViewers);
832 setCentralWidget(splitter1);
833
834 splitter2->show();
835 splitter3->show();
836 splitter1->show();
837
838
839
840 QList<int> sizes;
841 sizes << height()-200 << 200;
842 splitter2->setSizes( sizes );
843 sizes.clear();
844 sizes << 180 << (int) (width()-180)*0.5 << (int) (width()-180)*0.5;
845 splitter1->setSizes( sizes );
846 sizes.clear();
847 sizes << height()-50 << 50;
848 splitter3->setSizes( sizes );
849
850
851
852
853 createStatusBar();
854 setupMenus();
855 setupToolBars();
856
857
858
859 connect(QApplication::clipboard(), SIGNAL(dataChanged()), this, SLOT(clipboardDataChanged()));
860
861 QPalette pal = QApplication::palette();
862 QColor col=pal.color(QPalette::Window);
863
864 if (new_gui)
865 {
866 restoreState(windowstate, 0);
867 if (winmaximized) this->setWindowState(Qt::WindowMaximized);
868 splitter1->restoreState(splitter1state);
869 splitter2->restoreState(splitter2state);
870 splitter3->restoreState(splitter3state);
871 }
872
873
874
875 ShowOutputView(false);
876 ShowStructView(false);
877 ShowFilesView(false);
878
879 sourceviewerWidget=new SourceView(StackedViewers,EditorFont,showline,edcolors(),hicolors());
880 sourceviewerWidget->editor->setEncoding(input_encoding);
881 if (wordwrap) {sourceviewerWidget->editor->setWordWrapMode(QTextOption::WordWrap);}
882 else {sourceviewerWidget->editor->setWordWrapMode(QTextOption::NoWrap);}
883 connect (sourceviewerWidget, SIGNAL(showDiff()), this, SLOT(compareDocuments()));
884 StackedViewers->addWidget(sourceviewerWidget);
885
886 ShowPdfView(false);
887 ShowSourceView(false);
888
889 if (embedinternalpdf && builtinpdfview && showpdfview )
890 {
891 StackedViewers->show();
892 sourceviewerWidget->hide();
893 }
894 else if (showsourceview)
895 {
896 StackedViewers->setCurrentWidget(sourceviewerWidget);
897 StackedViewers->show();
898 }
899 else StackedViewers->hide();
900
901 UpdateRecentFile();
902
903 UpdateCaption();
904 singlemode=true;
905 ToggleDocAct->setEnabled(false);
906 MasterName=getName();
907
908 show();
909
910 splitter2Changed();
911
912
913
914 LeftPanelToolBarBis->setMinimumHeight(centralToolBarBis->height());
915 sourceviewerWidget->centralToolBar->setMinimumHeight(centralToolBarBis->height());
916 sourceviewerWidget->centralToolBar->setMaximumHeight(centralToolBarBis->height());
917 stat1->setText(QString(" %1 ").arg(tr("Normal Mode")));
918 //stat2->setText(QString(" %1 ").arg(tr("Ready")));
919 stat3->setText(QString(" %1 ").arg(input_encoding));
920
921 setAcceptDrops(true);
922 autosaveTimer = new QTimer(this);
923 if (autosave)
924 {
925 connect(autosaveTimer, SIGNAL(timeout()), this, SLOT(fileBackupAll()));
926 autosaveTimer->start(600000);
927 }
928
929 }
930
~Texmaker()931 Texmaker::~Texmaker(){
932 if (spellChecker) delete spellChecker;
933 }
934
setupMenus()935 void Texmaker::setupMenus()
936 {
937 QAction *Act;
938 //bool gtkEnv=gtkSession();
939 bool gtkEnv=false;
940 //file
941 fileMenu = menuBar()->addMenu(tr("&File"));
942 if (gtkEnv) Act = new QAction(QIcon::fromTheme("document-new", QIcon(":/images/filenew.png")), tr("New"), this);
943 else Act = new QAction(getIcon(":/images/filenew.png"), tr("New"), this);
944 Act->setShortcut(Qt::CTRL+Qt::Key_N);
945 connect(Act, SIGNAL(triggered()), this, SLOT(fileNew()));
946 fileMenu->addAction(Act);
947
948 Act = new QAction(tr("New by copying an existing file"), this);
949 connect(Act, SIGNAL(triggered()), this, SLOT(fileNewFromFile()));
950 fileMenu->addAction(Act);
951
952 if (gtkEnv) Act = new QAction(QIcon::fromTheme("document-open", QIcon(":/images/fileopen.png")), tr("Open"), this);
953 else Act = new QAction(getIcon(":/images/fileopen.png"), tr("Open"), this);
954 Act->setShortcut(Qt::CTRL+Qt::Key_O);
955 connect(Act, SIGNAL(triggered()), this, SLOT(fileOpen()));
956 fileMenu->addAction(Act);
957
958 recentMenu=fileMenu->addMenu(tr("Open Recent"));
959 for (int i = 0; i < 10; ++i)
960 {
961 recentFileActs[i] = new QAction(this);
962 recentFileActs[i]->setVisible(false);
963 connect(recentFileActs[i], SIGNAL(triggered()),this, SLOT(fileOpenRecent()));
964 recentMenu->addAction(recentFileActs[i]);
965 }
966 recentMenu->addSeparator();
967 Act = new QAction(tr("Clean"), this);
968 connect(Act, SIGNAL(triggered()), this, SLOT(CleanRecent()));
969 recentMenu->addAction(Act);
970
971 sessionMenu=fileMenu->addMenu(tr("Session"));
972 Act = new QAction(tr("Restore previous session"), this);
973 Act->setShortcut(Qt::CTRL+Qt::SHIFT+Qt::Key_F8);
974 connect(Act, SIGNAL(triggered()), this, SLOT(LoadLastSession()));
975 sessionMenu->addAction(Act);
976
977 Act = new QAction(tr("Save session"), this);
978 connect(Act, SIGNAL(triggered()), this, SLOT(SaveSession()));
979 sessionMenu->addAction(Act);
980 Act = new QAction(tr("Load session"), this);
981 connect(Act, SIGNAL(triggered()), this, SLOT(LoadSession()));
982 sessionMenu->addAction(Act);
983
984 if (gtkEnv) SaveAct = new QAction(QIcon::fromTheme("document-save", QIcon(":/images/filesave.png")), tr("Save"), this);
985 else SaveAct = new QAction(getIcon(":/images/filesave.png"), tr("Save"), this);
986 SaveAct->setShortcut(Qt::CTRL+Qt::Key_S);
987 connect(SaveAct, SIGNAL(triggered()), this, SLOT(fileSave()));
988 fileMenu->addAction(SaveAct);
989 fileMenu->addSeparator();
990
991
992 Act = new QAction(tr("Save As"), this);
993 connect(Act, SIGNAL(triggered()), this, SLOT(fileSaveAs()));
994 fileMenu->addAction(Act);
995
996 Act = new QAction(tr("Save All"), this);
997 connect(Act, SIGNAL(triggered()), this, SLOT(fileSaveAll()));
998 fileMenu->addAction(Act);
999
1000 Act = new QAction(tr("Save A Copy"), this);
1001 connect(Act, SIGNAL(triggered()), this, SLOT(fileSaveACopy()));
1002 fileMenu->addAction(Act);
1003
1004 Act = new QAction(getIcon(":/images/fileclose.png"), tr("Close"), this);
1005 Act->setShortcut(Qt::CTRL+Qt::Key_W);
1006 connect(Act, SIGNAL(triggered()), this, SLOT(fileClose()));
1007 fileMenu->addSeparator();
1008 fileMenu->addAction(Act);
1009
1010 Act = new QAction(tr("Close All"), this);
1011 connect(Act, SIGNAL(triggered()), this, SLOT(fileCloseAll()));
1012 fileMenu->addAction(Act);
1013
1014 Act = new QAction(tr("Reload document from file"), this);
1015 connect(Act, SIGNAL(triggered()), this, SLOT(fileReload()));
1016 fileMenu->addAction(Act);
1017
1018 Act = new QAction(tr("Reload all documents from file"), this);
1019 connect(Act, SIGNAL(triggered()), this, SLOT(allReload()));
1020 fileMenu->addAction(Act);
1021
1022 Act = new QAction(tr("Print"), this);
1023 Act->setShortcut(Qt::CTRL+Qt::Key_P);
1024 connect(Act, SIGNAL(triggered()), this, SLOT(filePrint()));
1025 fileMenu->addSeparator();
1026 fileMenu->addAction(Act);
1027
1028 if (gtkEnv) Act = new QAction(QIcon::fromTheme("application-exit", QIcon(":/images/exit.png")), tr("Exit"), this);
1029 else Act = new QAction(getIcon(":/images/exit.png"), tr("Exit"), this);
1030 Act->setShortcut(Qt::CTRL+Qt::Key_Q);
1031 connect(Act, SIGNAL(triggered()), this, SLOT(fileExit()));
1032 fileMenu->addSeparator();
1033 fileMenu->addAction(Act);
1034
1035 editMenu = menuBar()->addMenu(tr("&Edit"));
1036 if (gtkEnv) UndoAct = new QAction(QIcon::fromTheme("edit-undo", QIcon(":/images/undo.png")), tr("Undo"), this);
1037 else UndoAct = new QAction(getIcon(":/images/undo.png"), tr("Undo"), this);
1038 UndoAct->setShortcut(Qt::CTRL+Qt::Key_Z);
1039 connect(UndoAct, SIGNAL(triggered()), this, SLOT(editUndo()));
1040 editMenu->addAction(UndoAct);
1041
1042 if (gtkEnv) RedoAct = new QAction(QIcon::fromTheme("edit-redo", QIcon(":/images/redo.png")), tr("Redo"), this);
1043 else RedoAct = new QAction(getIcon(":/images/redo.png"), tr("Redo"), this);
1044 RedoAct->setShortcut(Qt::CTRL+Qt::Key_Y);
1045 connect(RedoAct, SIGNAL(triggered()), this, SLOT(editRedo()));
1046 editMenu->addAction(RedoAct);
1047 editMenu->addSeparator();
1048
1049 if (gtkEnv) CopyAct = new QAction(QIcon::fromTheme("edit-copy", QIcon(":/images/editcopy.png")), tr("Copy"), this);
1050 else CopyAct = new QAction(getIcon(":/images/editcopy.png"), tr("Copy"), this);
1051 CopyAct->setShortcut(Qt::CTRL+Qt::Key_C);
1052 connect(CopyAct, SIGNAL(triggered()), this, SLOT(editCopy()));
1053 editMenu->addAction(CopyAct);
1054
1055 if (gtkEnv) CutAct = new QAction(QIcon::fromTheme("edit-cut", QIcon(":/images/editcut.png")), tr("Cut"), this);
1056 else CutAct = new QAction(getIcon(":/images/editcut.png"), tr("Cut"), this);
1057 CutAct->setShortcut(Qt::CTRL+Qt::Key_X);
1058 connect(CutAct, SIGNAL(triggered()), this, SLOT(editCut()));
1059 editMenu->addAction(CutAct);
1060
1061 if (gtkEnv) PasteAct = new QAction(QIcon::fromTheme("edit-paste", QIcon(":/images/editpaste.png")), tr("Paste"), this);
1062 else PasteAct = new QAction(getIcon(":/images/editpaste.png"), tr("Paste"), this);
1063 PasteAct->setShortcut(Qt::CTRL+Qt::Key_V);
1064 connect(PasteAct, SIGNAL(triggered()), this, SLOT(editPaste()));
1065 editMenu->addAction(PasteAct);
1066
1067 Act = new QAction( tr("Select All"), this);
1068 Act->setShortcut(Qt::CTRL+Qt::Key_A);
1069 connect(Act, SIGNAL(triggered()), this, SLOT(editSelectAll()));
1070 editMenu->addAction(Act);
1071 editMenu->addSeparator();
1072
1073 Act = new QAction( tr("Comment"), this);
1074 Act->setData("Comment");
1075 Act->setShortcut(Qt::CTRL+Qt::Key_T);
1076 connect(Act, SIGNAL(triggered()), this, SLOT(editComment()));
1077 editMenu->addAction(Act);
1078
1079 Act = new QAction( tr("Uncomment"), this);
1080 Act->setData("Uncomment");
1081 Act->setShortcut(Qt::CTRL+Qt::Key_U);
1082 connect(Act, SIGNAL(triggered()), this, SLOT(editUncomment()));
1083 editMenu->addAction(Act);
1084
1085 Act = new QAction( tr("Indent"), this);
1086 Act->setData("Indent");
1087 Act->setShortcut(Qt::CTRL+Qt::Key_Greater);
1088 connect(Act, SIGNAL(triggered()), this, SLOT(editIndent()));
1089 editMenu->addAction(Act);
1090
1091 Act = new QAction( tr("Unindent"), this);
1092 Act->setData("Unindent");
1093 Act->setShortcut(Qt::CTRL+Qt::Key_Less);
1094 connect(Act, SIGNAL(triggered()), this, SLOT(editUnindent()));
1095 editMenu->addAction(Act);
1096 editMenu->addSeparator();
1097
1098 Act = new QAction( tr("Fold"), this);
1099 Act->setShortcut(Qt::CTRL+Qt::Key_BracketLeft);
1100 connect(Act, SIGNAL(triggered()), this, SLOT(foldEnclosing()));
1101 editMenu->addAction(Act);
1102 Act = new QAction( tr("Unfold"), this);
1103 Act->setShortcut(Qt::CTRL+Qt::Key_BracketRight);
1104 connect(Act, SIGNAL(triggered()), this, SLOT(unfoldEnclosing()));
1105 editMenu->addAction(Act);
1106
1107 foldMenu=editMenu->addMenu(tr("&Fold All"));
1108 Act = new QAction("Parts", this);
1109 Act->setData(0);
1110 connect(Act, SIGNAL(triggered()), this, SLOT(foldAll()));
1111 foldMenu->addAction(Act);
1112 Act = new QAction("Chapters", this);
1113 Act->setData(1);
1114 connect(Act, SIGNAL(triggered()), this, SLOT(foldAll()));
1115 foldMenu->addAction(Act);
1116 Act = new QAction("Sections", this);
1117 Act->setData(2);
1118 connect(Act, SIGNAL(triggered()), this, SLOT(foldAll()));
1119 foldMenu->addAction(Act);
1120 Act = new QAction("Subsections", this);
1121 Act->setData(3);
1122 connect(Act, SIGNAL(triggered()), this, SLOT(foldAll()));
1123 foldMenu->addAction(Act);
1124 Act = new QAction("Subsubsections", this);
1125 Act->setData(4);
1126 connect(Act, SIGNAL(triggered()), this, SLOT(foldAll()));
1127 foldMenu->addAction(Act);
1128 foldMenu->addSeparator();
1129 Act = new QAction("Parts+", this);
1130 Act->setData(0);
1131 connect(Act, SIGNAL(triggered()), this, SLOT(foldAllUnder()));
1132 foldMenu->addAction(Act);
1133 Act = new QAction("Chapters+", this);
1134 Act->setData(1);
1135 connect(Act, SIGNAL(triggered()), this, SLOT(foldAllUnder()));
1136 foldMenu->addAction(Act);
1137 Act = new QAction("Sections+", this);
1138 Act->setData(2);
1139 connect(Act, SIGNAL(triggered()), this, SLOT(foldAllUnder()));
1140 foldMenu->addAction(Act);
1141 Act = new QAction("Subsections+", this);
1142 Act->setData(3);
1143 connect(Act, SIGNAL(triggered()), this, SLOT(foldAllUnder()));
1144 foldMenu->addAction(Act);
1145 Act = new QAction("Subsubsections+", this);
1146 Act->setData(4);
1147 connect(Act, SIGNAL(triggered()), this, SLOT(foldAllUnder()));
1148 foldMenu->addAction(Act);
1149
1150 unfoldMenu=editMenu->addMenu(tr("&Unfold All"));
1151 Act = new QAction("Parts", this);
1152 Act->setData(0);
1153 connect(Act, SIGNAL(triggered()), this, SLOT(unfoldAll()));
1154 unfoldMenu->addAction(Act);
1155 Act = new QAction("Chapters", this);
1156 Act->setData(1);
1157 connect(Act, SIGNAL(triggered()), this, SLOT(unfoldAll()));
1158 unfoldMenu->addAction(Act);
1159 Act = new QAction("Sections", this);
1160 Act->setData(2);
1161 connect(Act, SIGNAL(triggered()), this, SLOT(unfoldAll()));
1162 unfoldMenu->addAction(Act);
1163 Act = new QAction("Subsection", this);
1164 Act->setData(3);
1165 connect(Act, SIGNAL(triggered()), this, SLOT(unfoldAll()));
1166 unfoldMenu->addAction(Act);
1167 Act = new QAction("Subsubsection", this);
1168 Act->setData(4);
1169 unfoldMenu->addAction(Act);
1170 connect(Act, SIGNAL(triggered()), this, SLOT(unfoldAllUnder()));
1171 unfoldMenu->addAction(Act);
1172 unfoldMenu->addSeparator();
1173 Act = new QAction("Parts+", this);
1174 Act->setData(0);
1175 connect(Act, SIGNAL(triggered()), this, SLOT(unfoldAllUnder()));
1176 unfoldMenu->addAction(Act);
1177 Act = new QAction("Chapters+", this);
1178 Act->setData(1);
1179 connect(Act, SIGNAL(triggered()), this, SLOT(unfoldAllUnder()));
1180 unfoldMenu->addAction(Act);
1181 Act = new QAction("Sections+", this);
1182 Act->setData(2);
1183 connect(Act, SIGNAL(triggered()), this, SLOT(unfoldAllUnder()));
1184 unfoldMenu->addAction(Act);
1185 Act = new QAction("Subsections+", this);
1186 Act->setData(3);
1187 connect(Act, SIGNAL(triggered()), this, SLOT(unfoldAllUnder()));
1188 unfoldMenu->addAction(Act);
1189 Act = new QAction("Subsubsection+", this);
1190 Act->setData(4);
1191 connect(Act, SIGNAL(triggered()), this, SLOT(unfoldAllUnder()));
1192 unfoldMenu->addAction(Act);
1193
1194 editMenu->addSeparator();
1195
1196
1197 Act = new QAction( tr("Find"), this);
1198 Act->setData("Find");
1199 Act->setShortcut(Qt::CTRL+Qt::Key_F);
1200 connect(Act, SIGNAL(triggered()), this, SLOT(editFind()));
1201 editMenu->addAction(Act);
1202
1203 Act = new QAction( tr("FindNext"), this);
1204 Act->setData("FindNext");
1205 Act->setShortcut(Qt::CTRL+Qt::Key_M);
1206 connect(Act, SIGNAL(triggered()), this, SLOT(editFindNext()));
1207 editMenu->addAction(Act);
1208
1209 Act = new QAction( tr("Find In Directory"), this);
1210 Act->setData("Find In Directory");
1211 connect(Act, SIGNAL(triggered()), this, SLOT(editFindInDirectory()));
1212 editMenu->addAction(Act);
1213
1214 Act = new QAction( tr("Replace"), this);
1215 Act->setData("Replace");
1216 Act->setShortcut(Qt::CTRL+Qt::Key_R);
1217 connect(Act, SIGNAL(triggered()), this, SLOT(editReplace()));
1218 editMenu->addAction(Act);
1219
1220 Act = new QAction(getIcon(":/images/goto.png"), tr("Goto Line"), this);
1221 Act->setData("Goto Line");
1222 Act->setShortcut(Qt::CTRL+Qt::Key_G);
1223 connect(Act, SIGNAL(triggered()), this, SLOT(editGotoLine()));
1224 editMenu->addAction(Act);
1225 editMenu->addSeparator();
1226
1227 Act = new QAction(tr("Check Spelling"), this);
1228 Act->setData("Check Spelling");
1229 Act->setShortcut(Qt::CTRL+Qt::SHIFT+Qt::Key_F7);
1230 connect(Act, SIGNAL(triggered()), this, SLOT(editSpell()));
1231 editMenu->addAction(Act);
1232 editMenu->addSeparator();
1233
1234 Act = new QAction(tr("Refresh Structure"), this);
1235 Act->setData("Refresh Structure");
1236 Act->setShortcut(Qt::CTRL+Qt::SHIFT+Qt::Key_F1);
1237 connect(Act, SIGNAL(triggered()), this, SLOT(refreshAll()));
1238 editMenu->addAction(Act);
1239
1240 Act = new QAction(tr("Refresh Bibliography"), this);
1241 Act->setData("Refresh Bibliography");
1242 connect(Act, SIGNAL(triggered()), this, SLOT(UpdateBibliography()));
1243 editMenu->addAction(Act);
1244
1245 toolMenu = menuBar()->addMenu(tr("&Tools"));
1246 Act = new QAction(getIcon(":/images/quick.png"),tr("Quick Build"), this);
1247 Act->setData(Act->text());
1248 Act->setShortcut(Qt::Key_F1);
1249 connect(Act, SIGNAL(triggered()), this, SLOT(QuickBuild()));
1250 toolMenu->addAction(Act);
1251 toolMenu->addSeparator();
1252 Act = new QAction("LaTeX", this);
1253 Act->setData("LaTeX");
1254 Act->setShortcut(Qt::Key_F2);
1255 connect(Act, SIGNAL(triggered()), this, SLOT(Latex()));
1256 toolMenu->addAction(Act);
1257 Act = new QAction(tr("View Dvi"), this);
1258 Act->setData("View Dvi");
1259 Act->setShortcut(Qt::Key_F3);
1260 connect(Act, SIGNAL(triggered()), this, SLOT(ViewDvi()));
1261 toolMenu->addAction(Act);
1262 Act = new QAction("Dvi->PS", this);
1263 Act->setData("Dvi->PS");
1264 Act->setShortcut(Qt::Key_F4);
1265 connect(Act, SIGNAL(triggered()), this, SLOT(DviToPS()));
1266 toolMenu->addAction(Act);
1267 Act = new QAction(tr("View PS"), this);
1268 Act->setData("View PS");
1269 Act->setShortcut(Qt::Key_F5);
1270 connect(Act, SIGNAL(triggered()), this, SLOT(ViewPS()));
1271 toolMenu->addAction(Act);
1272 Act = new QAction("PDFLaTeX", this);
1273 Act->setData("PDFLaTeX");
1274 Act->setShortcut(Qt::Key_F6);
1275 connect(Act, SIGNAL(triggered()), this, SLOT(PDFLatex()));
1276 toolMenu->addAction(Act);
1277 Act = new QAction(tr("View PDF"), this);
1278 Act->setData("View PDF");
1279 Act->setShortcut(Qt::Key_F7);
1280 connect(Act, SIGNAL(triggered()), this, SLOT(ViewPDF()));
1281 toolMenu->addAction(Act);
1282 Act = new QAction("PS->PDF", this);
1283 Act->setData("PS->PDF");
1284 Act->setShortcut(Qt::Key_F8);
1285 connect(Act, SIGNAL(triggered()), this, SLOT(PStoPDF()));
1286 toolMenu->addAction(Act);
1287 Act = new QAction("DVI->PDF", this);
1288 Act->setData("DVI->PDF");
1289 Act->setShortcut(Qt::Key_F9);
1290 connect(Act, SIGNAL(triggered()), this, SLOT(DVItoPDF()));
1291 toolMenu->addAction(Act);
1292 Act = new QAction(tr("View Log"), this);
1293 Act->setData("View Log");
1294 Act->setShortcut(Qt::Key_F10);
1295 connect(Act, SIGNAL(triggered()), this, SLOT(ViewLog()));
1296 toolMenu->addAction(Act);
1297 Act = new QAction("BibTeX", this);
1298 Act->setData("BibTeX");
1299 Act->setShortcut(Qt::Key_F11);
1300 connect(Act, SIGNAL(triggered()), this, SLOT(MakeBib()));
1301 toolMenu->addAction(Act);
1302 Act = new QAction("MakeIndex", this);
1303 Act->setData("MakeIndex");
1304 Act->setShortcut(Qt::Key_F12);
1305 connect(Act, SIGNAL(triggered()), this, SLOT(MakeIndex()));
1306 toolMenu->addAction(Act);
1307 toolMenu->addSeparator();
1308 Act = new QAction("MPost", this);
1309 Act->setData("MPost");
1310 connect(Act, SIGNAL(triggered()), this, SLOT(MetaPost()));
1311 toolMenu->addAction(Act);
1312 Act = new QAction("Asymptote", this);
1313 Act->setData("Asymptote");
1314 connect(Act, SIGNAL(triggered()), this, SLOT(Asymptote()));
1315 toolMenu->addAction(Act);
1316 Act = new QAction("Latexmk", this);
1317 Act->setData("Latexmk");
1318 connect(Act, SIGNAL(triggered()), this, SLOT(LatexMk()));
1319 toolMenu->addAction(Act);
1320 Act = new QAction("R Sweave", this);
1321 Act->setData("R Sweave");
1322 connect(Act, SIGNAL(triggered()), this, SLOT(Sweave()));
1323 toolMenu->addAction(Act);
1324 Act = new QAction("XeLaTeX", this);
1325 Act->setData("XeLaTeX");
1326 toolMenu->addAction(Act);
1327 connect(Act, SIGNAL(triggered()), this, SLOT(Xelatex()));
1328 Act = new QAction("LuaLaTeX", this);
1329 Act->setData("LuaLaTeX");
1330 connect(Act, SIGNAL(triggered()), this, SLOT(Lualatex()));
1331 toolMenu->addAction(Act);
1332 toolMenu->addSeparator();
1333 Act = new QAction(tr("Clean"), this);
1334 Act->setData("Clean");
1335 connect(Act, SIGNAL(triggered()), this, SLOT(CleanAll()));
1336 toolMenu->addAction(Act);
1337 toolMenu->addSeparator();
1338 Act = new QAction(tr("Open Terminal"), this);
1339 Act->setData("Open Terminal");
1340 connect(Act, SIGNAL(triggered()), this, SLOT(OpenTerminal()));
1341 toolMenu->addAction(Act);
1342 Act = new QAction(tr("Export via TeX4ht"), this);
1343 Act->setData("Export via TeX4ht");
1344 connect(Act, SIGNAL(triggered()), this, SLOT(Export()));
1345 toolMenu->addAction(Act);
1346 toolMenu->addSeparator();
1347 Act = new QAction(tr("Convert to unicode"), this);
1348 Act->setData("Convert to unicode");
1349 connect(Act, SIGNAL(triggered()), this, SLOT(ConvertToUnicode()));
1350 toolMenu->addAction(Act);
1351
1352 Act = new QAction(getIcon(":/images/errorprev.png"),tr("Previous LaTeX Error"), this);
1353 connect(Act, SIGNAL(triggered()), this, SLOT(PreviousError()));
1354 Act = new QAction(getIcon(":/images/errornext.png"),tr("Next LaTeX Error"), this);
1355 connect(Act, SIGNAL(triggered()), this, SLOT(NextError()));
1356
1357 latex1Menu = menuBar()->addMenu(tr("&LaTeX"));
1358 Act = new QAction("\\documentclass", this);
1359 Act->setData("\\documentclass[10pt]{}/21/0/\\documentclass[options]{class}");
1360 connect(Act, SIGNAL(triggered()), this, SLOT(InsertFromAction()));
1361 latex1Menu->addAction(Act);
1362 Act = new QAction("\\usepackage{}", this);
1363 Act->setData("\\usepackage{} /12/0/\\usepackage[options]{pkg}");
1364 connect(Act, SIGNAL(triggered()), this, SLOT(InsertFromAction()));
1365 latex1Menu->addAction(Act);
1366 Act = new QAction("AMS packages", this);
1367 Act->setData("\\usepackage{amsmath}\n\\usepackage{amsfonts}\n\\usepackage{amssymb}\n/0/3/The main American Mathematical Society packages");
1368 connect(Act, SIGNAL(triggered()), this, SLOT(InsertFromAction()));
1369 latex1Menu->addAction(Act);
1370 Act = new QAction("\\begin{document}", this);
1371 Act->setData("\\begin{document}\n\n\\end{document}/0/1/Text is allowed only between \\begin{document} and \\end{document}.");
1372 connect(Act, SIGNAL(triggered()), this, SLOT(InsertFromAction()));
1373 latex1Menu->addAction(Act);
1374 Act = new QAction("\\author{}", this);
1375 Act->setData("\\author{}/8/0/\\author{names}\nThe \\author command declares the author(s), where names is a list of authors separated by \\and commands.");
1376 connect(Act, SIGNAL(triggered()), this, SLOT(InsertFromAction()));
1377 latex1Menu->addAction(Act);
1378 Act = new QAction("\\title{}", this);
1379 Act->setData("\\title{}/7/0/\\title{text}\nThe \\title command declares text to be the title.");
1380 connect(Act, SIGNAL(triggered()), this, SLOT(InsertFromAction()));
1381 latex1Menu->addAction(Act);
1382 Act = new QAction("\\maketitle", this);
1383 Act->setData("\\maketitle/10/0/This command generates a title on a separate title page\n- except in the article class, where the title normally goes at the top of the first page.");
1384 connect(Act, SIGNAL(triggered()), this, SLOT(InsertFromAction()));
1385 latex1Menu->addAction(Act);
1386 Act = new QAction("\\tableofcontents", this);
1387 Act->setData("\\tableofcontents/16/0/Put this command where you want the table of contents to go");
1388 connect(Act, SIGNAL(triggered()), this, SLOT(InsertFromAction()));
1389 latex1Menu->addAction(Act);
1390
1391 latex11Menu=latex1Menu->addMenu(tr("&Sectioning"));
1392 Act = new QAction("\\part", this);
1393 Act->setData("\\part");
1394 connect(Act, SIGNAL(triggered()), this, SLOT(InsertStruct()));
1395 latex11Menu->addAction(Act);
1396 Act = new QAction("\\chapter", this);
1397 Act->setData("\\chapter");
1398 connect(Act, SIGNAL(triggered()), this, SLOT(InsertStruct()));
1399 latex11Menu->addAction(Act);
1400 Act = new QAction("\\section", this);
1401 Act->setData("\\section");
1402 connect(Act, SIGNAL(triggered()), this, SLOT(InsertStruct()));
1403 latex11Menu->addAction(Act);
1404 Act = new QAction("\\subsection", this);
1405 Act->setData("\\subsection");
1406 connect(Act, SIGNAL(triggered()), this, SLOT(InsertStruct()));
1407 latex11Menu->addAction(Act);
1408 Act = new QAction("\\subsubsection", this);
1409 Act->setData("\\subsubsection");
1410 connect(Act, SIGNAL(triggered()), this, SLOT(InsertStruct()));
1411 latex11Menu->addAction(Act);
1412 Act = new QAction("\\paragraph", this);
1413 Act->setData("\\paragraph");
1414 connect(Act, SIGNAL(triggered()), this, SLOT(InsertStruct()));
1415 latex11Menu->addAction(Act);
1416 Act = new QAction("\\subparagraph", this);
1417 Act->setData("\\subparagraph");
1418 connect(Act, SIGNAL(triggered()), this, SLOT(InsertStruct()));
1419 latex11Menu->addAction(Act);
1420
1421 latex12Menu=latex1Menu->addMenu(tr("&Environment"));
1422 Act = new QAction(getIcon(":/images/text_center.png"),"\\begin{center} [selection]", this);
1423 Act->setData("\\begin{center}\n/\n\\end{center}/0/1");
1424 connect(Act, SIGNAL(triggered()), this, SLOT(InsertWithSelectionFromAction()));
1425 latex12Menu->addAction(Act);
1426 Act = new QAction(getIcon(":/images/text_left.png"),"\\begin{flushleft} [selection]", this);
1427 Act->setData("\\begin{flushleft}\n/\n\\end{flushleft}/0/1");
1428 connect(Act, SIGNAL(triggered()), this, SLOT(InsertWithSelectionFromAction()));
1429 latex12Menu->addAction(Act);
1430 Act = new QAction(getIcon(":/images/text_right.png"),"\\begin{flushright} [selection]", this);
1431 Act->setData("\\begin{flushright}\n/\n\\end{flushright}/0/1");
1432 connect(Act, SIGNAL(triggered()), this, SLOT(InsertWithSelectionFromAction()));
1433 latex12Menu->addAction(Act);
1434 Act = new QAction("\\begin{quote} [selection]", this);
1435 Act->setData("\\begin{quote}\n/\n\\end{quote}/0/1");
1436 connect(Act, SIGNAL(triggered()), this, SLOT(InsertWithSelectionFromAction()));
1437 latex12Menu->addAction(Act);
1438 Act = new QAction("\\begin{quotation} [selection]", this);
1439 Act->setData("\\begin{quotation}\n/\n\\end{quotation}/0/1");
1440 connect(Act, SIGNAL(triggered()), this, SLOT(InsertWithSelectionFromAction()));
1441 latex12Menu->addAction(Act);
1442 Act = new QAction("\\begin{verse} [selection]", this);
1443 Act->setData("\\begin{verse}\n/\n\\end{verse}/0/1");
1444 connect(Act, SIGNAL(triggered()), this, SLOT(InsertWithSelectionFromAction()));
1445 latex12Menu->addAction(Act);
1446 Act = new QAction("\\begin{verbatim} [selection]", this);
1447 Act->setData("\\begin{verbatim}\n/\n\\end{verbatim}/0/1");
1448 connect(Act, SIGNAL(triggered()), this, SLOT(InsertWithSelectionFromAction()));
1449 latex12Menu->addAction(Act);
1450 Act = new QAction("\\begin{table} [selection]", this);
1451 Act->setData("\\begin{table}\n/\n\\caption{}\n\\end{table}/0/1");
1452 connect(Act, SIGNAL(triggered()), this, SLOT(InsertWithSelectionFromAction()));
1453 latex12Menu->addAction(Act);
1454 Act = new QAction("\\begin{figure} [selection]", this);
1455 Act->setData("\\begin{figure}\n/\n\\caption{}\n\\end{figure}/0/1");
1456 connect(Act, SIGNAL(triggered()), this, SLOT(InsertWithSelectionFromAction()));
1457 latex12Menu->addAction(Act);
1458 Act = new QAction("\\begin{titlepage} [selection]", this);
1459 Act->setData("\\begin{titlepage}\n/\n\\end{titlepage}/0/1");
1460 connect(Act, SIGNAL(triggered()), this, SLOT(InsertWithSelectionFromAction()));
1461 latex12Menu->addAction(Act);
1462 Act = new QAction("\\begin{minipage} [selection]", this);
1463 Act->setData("\\begin{minipage}{}\n/\n\\end{minipage}/0/1");
1464 connect(Act, SIGNAL(triggered()), this, SLOT(InsertWithSelectionFromAction()));
1465 latex12Menu->addAction(Act);
1466
1467 latex13Menu=latex1Menu->addMenu(tr("&List Environment"));
1468 Act = new QAction(getIcon(":/images/itemize.png"),"\\begin{itemize}", this);
1469 Act->setData("\\begin{itemize}\n\\item \n\\end{itemize}/6/1/The itemize environment produces a 'bulleted' list.\nEach item of an itemized list begins with an \\item command.");
1470 connect(Act, SIGNAL(triggered()), this, SLOT(InsertFromAction()));
1471 latex13Menu->addAction(Act);
1472 Act = new QAction(getIcon(":/images/enumerate.png"),"\\begin{enumerate}", this);
1473 Act->setData("\\begin{enumerate}\n\\item \n\\end{enumerate}/6/1/The enumerate environment produces a numbered list.\nEach item of an enumerated list begins with an \\item command.");
1474 connect(Act, SIGNAL(triggered()), this, SLOT(InsertFromAction()));
1475 latex13Menu->addAction(Act);
1476 Act = new QAction("\\begin{description}", this);
1477 Act->setData("\\begin{description}\n\\item[]\n\\end{description}/6/1/The description environment is used to make labelled lists.\nEach item of the list begins with an \\item[label] command.\n");
1478 connect(Act, SIGNAL(triggered()), this, SLOT(InsertFromAction()));
1479 latex13Menu->addAction(Act);
1480 Act = new QAction("\\begin{list}", this);
1481 Act->setData("\\begin{list}{}{}\n\\item \n\\end{list}/13/0/\\begin{list}{label}{spacing}\nThe {label} argument is a piece of text that is inserted in a box to form the label.\nThe {spacing} argument contains commands to change the spacing parameters for the list.\nEach item of the list begins with an \\item command.");
1482 connect(Act, SIGNAL(triggered()), this, SLOT(InsertFromAction()));
1483 latex13Menu->addAction(Act);
1484
1485 Act = new QAction(getIcon(":/images/item.png"),"\\item", this);
1486 Act->setShortcut(Qt::CTRL+Qt::SHIFT+Qt::Key_I);
1487 Act->setData("\\item/5/0/\\item[label] Hello");
1488 connect(Act, SIGNAL(triggered()), this, SLOT(InsertFromAction()));
1489 latex13Menu->addAction(Act);
1490
1491 latex14Menu=latex1Menu->addMenu(tr("Font St&yles"));
1492 Act = new QAction(getIcon(":/images/text_italic.png"),"\\textit - Italics [selection]", this);
1493 Act->setShortcut(Qt::CTRL+Qt::Key_I);
1494 Act->setData("\\textit{/}/8/0");
1495 connect(Act, SIGNAL(triggered()), this, SLOT(InsertWithSelectionFromAction()));
1496 latex14Menu->addAction(Act);
1497 Act = new QAction("\\textsl - Slanted [selection]", this);
1498 Act->setShortcut(Qt::CTRL+Qt::SHIFT+Qt::Key_S);
1499 Act->setData("\\textsl{/}/8/0");
1500 connect(Act, SIGNAL(triggered()), this, SLOT(InsertWithSelectionFromAction()));
1501 latex14Menu->addAction(Act);
1502 Act = new QAction(getIcon(":/images/text_bold.png"),"\\textbf - Boldface [selection]", this);
1503 Act->setShortcut(Qt::CTRL+Qt::Key_B);
1504 Act->setData("\\textbf{/}/8/0");
1505 connect(Act, SIGNAL(triggered()), this, SLOT(InsertWithSelectionFromAction()));
1506 latex14Menu->addAction(Act);
1507 Act = new QAction("\\texttt - Typewriter [selection]", this);
1508 Act->setShortcut(Qt::CTRL+Qt::SHIFT+Qt::Key_T);
1509 Act->setData("\\texttt{/}/8/0");
1510 connect(Act, SIGNAL(triggered()), this, SLOT(InsertWithSelectionFromAction()));
1511 latex14Menu->addAction(Act);
1512 Act = new QAction("\\textsc - Small caps [selection]", this);
1513 Act->setShortcut(Qt::CTRL+Qt::SHIFT+Qt::Key_C);
1514 Act->setData("\\textsc{/}/8/0");
1515 connect(Act, SIGNAL(triggered()), this, SLOT(InsertWithSelectionFromAction()));
1516 latex14Menu->addAction(Act);
1517 Act = new QAction("\\textsf - Sans Serif [selection]", this);
1518 Act->setShortcut(Qt::CTRL+Qt::SHIFT+Qt::Key_A);
1519 Act->setData("\\textsf{/}/8/0");
1520 connect(Act, SIGNAL(triggered()), this, SLOT(InsertWithSelectionFromAction()));
1521 latex14Menu->addAction(Act);
1522 Act = new QAction(getIcon(":/images/text_emphasis.png"),"\\emph - Emphasis [selection]", this);
1523 Act->setShortcut(Qt::CTRL+Qt::SHIFT+Qt::Key_E);
1524 Act->setData("\\emph{/}/6/0");
1525 connect(Act, SIGNAL(triggered()), this, SLOT(InsertWithSelectionFromAction()));
1526 latex14Menu->addAction(Act);
1527
1528 latex15Menu=latex1Menu->addMenu(tr("&Tabular Environment"));
1529 Act = new QAction("\\begin{tabbing}", this);
1530 Act->setData("\\begin{tabbing}\n\n\\end{tabbing}/0/1/\\begin{tabbing}\ntext \\= more text \\= still more text \\= last text \\\\\nsecond row \\> \\> more \\\\\n\\end{tabbing}");
1531 connect(Act, SIGNAL(triggered()), this, SLOT(InsertFromAction()));
1532 latex15Menu->addAction(Act);
1533 Act = new QAction("\\begin{tabular}", this);
1534 Act->setData("\\begin{tabular}{}\n\n\\end{tabular}/16/0/\\begin{tabular}[pos]{cols}\ncolumn 1 entry & column 2 entry ... & column n entry \\\\\n...\n\\end{tabular}");
1535 connect(Act, SIGNAL(triggered()), this, SLOT(InsertFromAction()));
1536 latex15Menu->addAction(Act);
1537 Act = new QAction("\\multicolumn", this);
1538 Act->setData("\\multicolumn{}{}{} /13/0/\\multicolumn{cols}{pos}{text}\ncol, specifies the number of columns to span.\npos specifies the formatting of the entry: c for centred, l for flushleft, r for flushright.\ntext specifies what text is to make up the entry.");
1539 connect(Act, SIGNAL(triggered()), this, SLOT(InsertFromAction()));
1540 latex15Menu->addAction(Act);
1541 Act = new QAction("\\hline", this);
1542 Act->setData("\\hline /7/0/The \\hline command draws a horizontal line the width of the table.");
1543 connect(Act, SIGNAL(triggered()), this, SLOT(InsertFromAction()));
1544 latex15Menu->addAction(Act);
1545 Act = new QAction("\\vline", this);
1546 Act->setData("\\vline /7/0/The \\vline command draws a vertical line extending the full height and depth of its row.");
1547 connect(Act, SIGNAL(triggered()), this, SLOT(InsertFromAction()));
1548 latex15Menu->addAction(Act);
1549 Act = new QAction("\\cline", this);
1550 Act->setData("\\cline{-} /7/0/The \\cline{i-j} command draws horizontal lines across the columns specified, beginning in column i and ending in column j");
1551 connect(Act, SIGNAL(triggered()), this, SLOT(InsertFromAction()));
1552 latex15Menu->addAction(Act);
1553
1554 latex16Menu=latex1Menu->addMenu(tr("S&pacing"));
1555 Act = new QAction("\\newpage", this);
1556 Act->setData("\\newpage /9/0/The \\newpage command ends the current page");
1557 connect(Act, SIGNAL(triggered()), this, SLOT(InsertFromAction()));
1558 latex16Menu->addAction(Act);
1559 Act = new QAction("\\linebreak", this);
1560 Act->setData("\\linebreak /11/0/The \\linebreak command tells LaTeX to break the current line at the point of the command.");
1561 connect(Act, SIGNAL(triggered()), this, SLOT(InsertFromAction()));
1562 latex16Menu->addAction(Act);
1563 Act = new QAction("\\pagebreak", this);
1564 Act->setData("\\pagebreak /11/0/The \\pagebreak command tells LaTeX to break the current page at the point of the command.");
1565 connect(Act, SIGNAL(triggered()), this, SLOT(InsertFromAction()));
1566 latex16Menu->addAction(Act);
1567 Act = new QAction("\\bigskip", this);
1568 Act->setData("\\bigskip /9/0/The \\bigskip command adds a 'big' vertical space.");
1569 connect(Act, SIGNAL(triggered()), this, SLOT(InsertFromAction()));
1570 latex16Menu->addAction(Act);
1571 Act = new QAction("\\medskip", this);
1572 Act->setData("\\medskip /9/0/The \\medskip command adds a 'medium' vertical space.");
1573 connect(Act, SIGNAL(triggered()), this, SLOT(InsertFromAction()));
1574 latex16Menu->addAction(Act);
1575 Act = new QAction(getIcon(":/images/newline.png"),"New line", this);
1576 Act->setData("\\\\\n/0/1/The \\newline command breaks the line right where it is.");
1577 Act->setShortcut(Qt::CTRL+Qt::Key_Return);
1578 connect(Act, SIGNAL(triggered()), this, SLOT(InsertFromAction()));
1579 latex16Menu->addAction(Act);
1580
1581 latex17Menu=latex1Menu->addMenu(tr("International &Accents"));
1582 Act = new QAction(getIcon(":/images/accent1.png"),"\\'{}", this);
1583 Act->setData("\\'{}/3/0/ ");
1584 connect(Act, SIGNAL(triggered()), this, SLOT(InsertFromAction()));
1585 latex17Menu->addAction(Act);
1586 Act = new QAction(getIcon(":/images/accent2.png"),"\\`{}", this);
1587 Act->setData("\\`{}/3/0/ ");
1588 connect(Act, SIGNAL(triggered()), this, SLOT(InsertFromAction()));
1589 latex17Menu->addAction(Act);
1590 Act = new QAction(getIcon(":/images/accent3.png"),"\\^{}", this);
1591 Act->setData("\\^{}/3/0/ ");
1592 connect(Act, SIGNAL(triggered()), this, SLOT(InsertFromAction()));
1593 latex17Menu->addAction(Act);
1594 Act = new QAction(getIcon(":/images/accent4.png"),"\\\"{}", this);
1595 Act->setData("\\\"{}/3/0/ ");
1596 connect(Act, SIGNAL(triggered()), this, SLOT(InsertFromAction()));
1597 latex17Menu->addAction(Act);
1598 Act = new QAction(getIcon(":/images/accent5.png"),"\\~{}", this);
1599 Act->setData("\\~{}/3/0/ ");
1600 connect(Act, SIGNAL(triggered()), this, SLOT(InsertFromAction()));
1601 latex17Menu->addAction(Act);
1602 Act = new QAction(getIcon(":/images/accent6.png"),"\\={}", this);
1603 Act->setData("\\={}/3/0/ ");
1604 connect(Act, SIGNAL(triggered()), this, SLOT(InsertFromAction()));
1605 latex17Menu->addAction(Act);
1606 Act = new QAction(getIcon(":/images/accent7.png"),"\\.{}", this);
1607 Act->setData("\\.{}/3/0/ ");
1608 connect(Act, SIGNAL(triggered()), this, SLOT(InsertFromAction()));
1609 latex17Menu->addAction(Act);
1610 Act = new QAction(getIcon(":/images/accent8.png"),"\\v{}", this);
1611 Act->setData("\\v{}/3/0/ ");
1612 connect(Act, SIGNAL(triggered()), this, SLOT(InsertFromAction()));
1613 latex17Menu->addAction(Act);
1614 Act = new QAction(getIcon(":/images/accent9.png"),"\\u{}", this);
1615 Act->setData("\\u{}/3/0/ ");
1616 connect(Act, SIGNAL(triggered()), this, SLOT(InsertFromAction()));
1617 latex17Menu->addAction(Act);
1618 Act = new QAction(getIcon(":/images/accent10.png"),"\\H{}", this);
1619 Act->setData("\\H{}/3/0/ ");
1620 connect(Act, SIGNAL(triggered()), this, SLOT(InsertFromAction()));
1621 latex17Menu->addAction(Act);
1622
1623 latex18Menu=latex1Menu->addMenu(tr("International &Quotes"));
1624 Act = new QAction("French Quotes [selection]", this);
1625 Act->setData("\\og / \\fg{}/4/0/ ");
1626 connect(Act, SIGNAL(triggered()), this, SLOT(InsertWithSelectionFromAction()));
1627 latex18Menu->addAction(Act);
1628 Act = new QAction("German Quotes [selection]", this);
1629 Act->setData("\\glqq /\\grqq/6/0/ ");
1630 connect(Act, SIGNAL(triggered()), this, SLOT(InsertWithSelectionFromAction()));
1631 latex18Menu->addAction(Act);
1632 Act = new QAction("Polish Quotes [selection]", this);
1633 Act->setData("\\quotedblbase /\\textquotedblright/14/0/ ");
1634 connect(Act, SIGNAL(triggered()), this, SLOT(InsertWithSelectionFromAction()));
1635 latex18Menu->addAction(Act);
1636
1637 Act = new QAction("\\includegraphics{file}", this);
1638 connect(Act, SIGNAL(triggered()), this, SLOT(InsertImage()));
1639 latex1Menu->addAction(Act);
1640 Act = new QAction("\\include{file}", this);
1641 connect(Act, SIGNAL(triggered()), this, SLOT(InsertInclude()));
1642 latex1Menu->addAction(Act);
1643 Act = new QAction("\\input{file}", this);
1644 connect(Act, SIGNAL(triggered()), this, SLOT(InsertInput()));
1645 latex1Menu->addAction(Act);
1646 latex1Menu->addSeparator();
1647
1648 Act = new QAction("\\label{}", this);
1649 Act->setData("\\label{} /7/0/\\label{key}");
1650 connect(Act, SIGNAL(triggered()), this, SLOT(InsertFromAction()));
1651 latex1Menu->addAction(Act);
1652 Act = new QAction("\\cite{}", this);
1653 Act->setData("\\cite{} /6/0/\\cite{ref} :\nThis command generates an in-text citation to the reference associated with the ref entry in the bib file");
1654 connect(Act, SIGNAL(triggered()), this, SLOT(InsertFromAction()));
1655 latex1Menu->addAction(Act);
1656 Act = new QAction("\\footnote{}", this);
1657 Act->setData("\\footnote{} /10/0/\\footnote[number]{text}\nThe \\footnote command places the numbered footnote text at the bottom of the current page.");
1658 connect(Act, SIGNAL(triggered()), this, SLOT(InsertFromAction()));
1659 latex1Menu->addAction(Act);
1660 Act = new QAction("\\bibliographystyle{}", this);
1661 Act->setData("\\bibliographystyle{} /19/0/The argument to \\bibliographystyle refers to a file style.bst, which defines how your citations will look");
1662 connect(Act, SIGNAL(triggered()), this, SLOT(InsertFromAction()));
1663 latex1Menu->addAction(Act);
1664 Act = new QAction("\\bibliography{}", this);
1665 connect(Act, SIGNAL(triggered()), this, SLOT(InsertBib()));
1666 latex1Menu->addAction(Act);
1667
1668 Act = new QAction("\\addbibresource{}", this);
1669 connect(Act, SIGNAL(triggered()), this, SLOT(InsertBibLatex()));
1670 latex1Menu->addAction(Act);
1671
1672 math1Menu = menuBar()->addMenu(tr("&Math"));
1673 Act = new QAction(tr("Inline math mode $...$"), this);
1674 Act->setShortcut(Qt::CTRL+Qt::SHIFT+Qt::Key_M);
1675 Act->setData("$"+QString(0x2022)+"$/2/0/The math environment can be used in both paragraph and LR mode");
1676 connect(Act, SIGNAL(triggered()), this, SLOT(InsertFromAction()));
1677 math1Menu->addAction(Act);
1678 Act = new QAction(tr("Display math mode \\[...\\]"), this);
1679 Act->setShortcut(Qt::ALT+Qt::SHIFT+Qt::Key_M);
1680 Act->setData("\\["+QString(0x2022)+"\\]/3/0/The displaymath environment can be used only in paragraph mode");
1681 connect(Act, SIGNAL(triggered()), this, SLOT(InsertFromAction()));
1682 math1Menu->addAction(Act);
1683 Act = new QAction(tr("Numbered equations \\begin{equation}"), this);
1684 Act->setShortcut(Qt::CTRL+Qt::SHIFT+Qt::Key_N);
1685 Act->setData("\\begin{equation}\n\n\\end{equation}/0/1/The equation environment centres your equation on the page and places the equation number in the right margin.");
1686 connect(Act, SIGNAL(triggered()), this, SLOT(InsertFromAction()));
1687 math1Menu->addAction(Act);
1688 Act = new QAction("\\begin{eqnarray}", this);
1689 Act->setData("\\begin{eqnarray}\n\n\\end{eqnarray}/0/1/\\begin{eqnarray}\nmath formula 1 \\\\\n\\end{eqnarray}\nThe eqnarray environment is used to display a sequence of equations or inequalities.");
1690 connect(Act, SIGNAL(triggered()), this, SLOT(InsertFromAction()));
1691 math1Menu->addAction(Act);
1692 Act = new QAction("\\begin{align} (AMS)", this);
1693 Act->setData("\\begin{align}\n\n\\end{align}/0/1/\\begin{align}\nmath formula 1 \\\\\n\\end{align}\nThe AMS align environment is used to display a sequence of equations or inequalities.");
1694 connect(Act, SIGNAL(triggered()), this, SLOT(InsertFromAction()));
1695 math1Menu->addAction(Act);
1696 Act = new QAction("_{} - subscript", this);
1697 Act->setShortcut(Qt::CTRL+Qt::SHIFT+Qt::Key_D);
1698 Act->setData("_{}/2/0/ ");
1699 connect(Act, SIGNAL(triggered()), this, SLOT(InsertFromAction()));
1700 math1Menu->addAction(Act);
1701 Act = new QAction("^{} - superscript", this);
1702 Act->setShortcut(Qt::CTRL+Qt::SHIFT+Qt::Key_U);
1703 Act->setData("^{}/2/0/ ");
1704 connect(Act, SIGNAL(triggered()), this, SLOT(InsertFromAction()));
1705 math1Menu->addAction(Act);
1706 Act = new QAction("\\frac{}{}", this);
1707 Act->setShortcut(Qt::ALT+Qt::SHIFT+Qt::Key_F);
1708 Act->setData("\\frac{}{}/6/0/ ");
1709 connect(Act, SIGNAL(triggered()), this, SLOT(InsertFromAction()));
1710 math1Menu->addAction(Act);
1711 Act = new QAction("\\dfrac{}{}", this);
1712 Act->setShortcut(Qt::CTRL+Qt::SHIFT+Qt::Key_F);
1713 Act->setData("\\dfrac{}{}/7/0/ ");
1714 connect(Act, SIGNAL(triggered()), this, SLOT(InsertFromAction()));
1715 math1Menu->addAction(Act);
1716 Act = new QAction("\\sqrt{}", this);
1717 Act->setShortcut(Qt::CTRL+Qt::SHIFT+Qt::Key_Q);
1718 Act->setData("\\sqrt{}/6/0/ ");
1719 connect(Act, SIGNAL(triggered()), this, SLOT(InsertFromAction()));
1720 math1Menu->addAction(Act);
1721 Act = new QAction("\\left", this);
1722 Act->setShortcut(Qt::CTRL+Qt::SHIFT+Qt::Key_L);
1723 Act->setData("\\left /6/0/ ");
1724 connect(Act, SIGNAL(triggered()), this, SLOT(InsertFromAction()));
1725 math1Menu->addAction(Act);
1726 Act = new QAction("\\right", this);
1727 Act->setShortcut(Qt::CTRL+Qt::SHIFT+Qt::Key_R);
1728 Act->setData("\\right /7/0/ ");
1729 connect(Act, SIGNAL(triggered()), this, SLOT(InsertFromAction()));
1730 math1Menu->addAction(Act);
1731 Act = new QAction("\\begin{array}", this);
1732 Act->setData("\\begin{array}{}\n\n\\end{array}/14/0/\\begin{array}{col1col2...coln}\ncolumn 1 entry & column 2 entry ... & column n entry \\\\\n...\n\\end{array}");
1733 connect(Act, SIGNAL(triggered()), this, SLOT(InsertFromAction()));
1734 math1Menu->addAction(Act);
1735
1736 math14Menu=math1Menu->addMenu(tr("Math &Functions"));
1737 Act = new QAction("\\arccos", this);
1738 Act->setData("\\arccos /8/0/ ");
1739 connect(Act, SIGNAL(triggered()), this, SLOT(InsertFromAction()));
1740 math14Menu->addAction(Act);
1741 Act = new QAction("\\arcsin", this);
1742 Act->setData("\\arcsin /8/0/ ");
1743 connect(Act, SIGNAL(triggered()), this, SLOT(InsertFromAction()));
1744 math14Menu->addAction(Act);
1745 Act = new QAction("\\arctan", this);
1746 Act->setData("\\arctan /8/0/ ");
1747 connect(Act, SIGNAL(triggered()), this, SLOT(InsertFromAction()));
1748 math14Menu->addAction(Act);
1749 Act = new QAction("\\cos", this);
1750 Act->setData("\\cos /5/0/ ");
1751 connect(Act, SIGNAL(triggered()), this, SLOT(InsertFromAction()));
1752 math14Menu->addAction(Act);
1753 Act = new QAction("\\cosh", this);
1754 Act->setData("\\cosh /6/0/ ");
1755 connect(Act, SIGNAL(triggered()), this, SLOT(InsertFromAction()));
1756 math14Menu->addAction(Act);
1757 Act = new QAction("\\cot", this);
1758 Act->setData("\\cot /5/0/ ");
1759 connect(Act, SIGNAL(triggered()), this, SLOT(InsertFromAction()));
1760 math14Menu->addAction(Act);
1761 Act = new QAction("\\coth", this);
1762 Act->setData("\\coth /6/0/ ");
1763 connect(Act, SIGNAL(triggered()), this, SLOT(InsertFromAction()));
1764 math14Menu->addAction(Act);
1765 Act = new QAction("\\csc", this);
1766 Act->setData("\\csc /5/0/ ");
1767 connect(Act, SIGNAL(triggered()), this, SLOT(InsertFromAction()));
1768 math14Menu->addAction(Act);
1769 Act = new QAction("\\deg", this);
1770 Act->setData("\\deg /5/0/ ");
1771 connect(Act, SIGNAL(triggered()), this, SLOT(InsertFromAction()));
1772 math14Menu->addAction(Act);
1773 Act = new QAction("\\det", this);
1774 Act->setData("\\det /5/0/ ");
1775 connect(Act, SIGNAL(triggered()), this, SLOT(InsertFromAction()));
1776 math14Menu->addAction(Act);
1777 Act = new QAction("\\dim", this);
1778 Act->setData("\\dim /5/0/ ");
1779 connect(Act, SIGNAL(triggered()), this, SLOT(InsertFromAction()));
1780 math14Menu->addAction(Act);
1781 Act = new QAction("\\exp", this);
1782 Act->setData("\\exp /5/0/ ");
1783 connect(Act, SIGNAL(triggered()), this, SLOT(InsertFromAction()));
1784 math14Menu->addAction(Act);
1785 Act = new QAction("\\gcd", this);
1786 Act->setData("\\gcd /5/0/ ");
1787 connect(Act, SIGNAL(triggered()), this, SLOT(InsertFromAction()));
1788 math14Menu->addAction(Act);
1789 Act = new QAction("\\hom", this);
1790 Act->setData("\\hom /5/0/ ");
1791 connect(Act, SIGNAL(triggered()), this, SLOT(InsertFromAction()));
1792 math14Menu->addAction(Act);
1793 Act = new QAction("\\inf", this);
1794 Act->setData("\\inf /5/0/ ");
1795 connect(Act, SIGNAL(triggered()), this, SLOT(InsertFromAction()));
1796 math14Menu->addAction(Act);
1797 Act = new QAction("\\ker", this);
1798 Act->setData("\\ker /5/0/ ");
1799 connect(Act, SIGNAL(triggered()), this, SLOT(InsertFromAction()));
1800 math14Menu->addAction(Act);
1801 Act = new QAction("\\lg", this);
1802 Act->setData("\\lg /4/0/ ");
1803 connect(Act, SIGNAL(triggered()), this, SLOT(InsertFromAction()));
1804 math14Menu->addAction(Act);
1805 Act = new QAction("\\lim", this);
1806 Act->setData("\\lim /5/0/ ");
1807 connect(Act, SIGNAL(triggered()), this, SLOT(InsertFromAction()));
1808 math14Menu->addAction(Act);
1809 Act = new QAction("\\liminf", this);
1810 Act->setData("\\liminf /8/0/ ");
1811 connect(Act, SIGNAL(triggered()), this, SLOT(InsertFromAction()));
1812 math14Menu->addAction(Act);
1813 Act = new QAction("\\limsup", this);
1814 Act->setData("\\limsup /8/0/ ");
1815 connect(Act, SIGNAL(triggered()), this, SLOT(InsertFromAction()));
1816 math14Menu->addAction(Act);
1817 Act = new QAction("\\ln", this);
1818 Act->setData("\\ln /4/0/ ");
1819 connect(Act, SIGNAL(triggered()), this, SLOT(InsertFromAction()));
1820 math14Menu->addAction(Act);
1821 Act = new QAction("\\log", this);
1822 Act->setData("\\log /5/0/ ");
1823 connect(Act, SIGNAL(triggered()), this, SLOT(InsertFromAction()));
1824 math14Menu->addAction(Act);
1825 Act = new QAction("\\max", this);
1826 Act->setData("\\max /5/0/ ");
1827 connect(Act, SIGNAL(triggered()), this, SLOT(InsertFromAction()));
1828 math14Menu->addAction(Act);
1829 Act = new QAction("\\min", this);
1830 Act->setData("\\min /5/0/ ");
1831 connect(Act, SIGNAL(triggered()), this, SLOT(InsertFromAction()));
1832 math14Menu->addAction(Act);
1833 Act = new QAction("\\sec", this);
1834 Act->setData("\\sec /5/0/ ");
1835 connect(Act, SIGNAL(triggered()), this, SLOT(InsertFromAction()));
1836 math14Menu->addAction(Act);
1837 Act = new QAction("\\sin", this);
1838 Act->setData("\\sin /5/0/ ");
1839 connect(Act, SIGNAL(triggered()), this, SLOT(InsertFromAction()));
1840 math14Menu->addAction(Act);
1841 Act = new QAction("\\sinh", this);
1842 Act->setData("\\sinh /6/0/ ");
1843 connect(Act, SIGNAL(triggered()), this, SLOT(InsertFromAction()));
1844 math14Menu->addAction(Act);
1845 Act = new QAction("\\sup", this);
1846 Act->setData("\\sup /5/0/ ");
1847 connect(Act, SIGNAL(triggered()), this, SLOT(InsertFromAction()));
1848 math14Menu->addAction(Act);
1849 Act = new QAction("\\tan", this);
1850 Act->setData("\\tan /5/0/ ");
1851 connect(Act, SIGNAL(triggered()), this, SLOT(InsertFromAction()));
1852 math14Menu->addAction(Act);
1853 Act = new QAction("\\tanh", this);
1854 Act->setData("\\tanh /6/0/ ");
1855 connect(Act, SIGNAL(triggered()), this, SLOT(InsertFromAction()));
1856 math14Menu->addAction(Act);
1857
1858 math11Menu=math1Menu->addMenu(tr("Math Font St&yles"));
1859 Act = new QAction("\\mathrm{} [selection]", this);
1860 Act->setData("\\mathrm{/}/8/0");
1861 connect(Act, SIGNAL(triggered()), this, SLOT(InsertWithSelectionFromAction()));
1862 math11Menu->addAction(Act);
1863 Act = new QAction("\\mathit{} [selection]", this);
1864 Act->setData("\\mathit{/}/8/0");
1865 connect(Act, SIGNAL(triggered()), this, SLOT(InsertWithSelectionFromAction()));
1866 math11Menu->addAction(Act);
1867 Act = new QAction("\\mathbf{} [selection]", this);
1868 Act->setData("\\mathbf{/}/8/0");
1869 connect(Act, SIGNAL(triggered()), this, SLOT(InsertWithSelectionFromAction()));
1870 math11Menu->addAction(Act);
1871 Act = new QAction("\\mathsf{} [selection]", this);
1872 Act->setData("\\mathsf{/}/8/0");
1873 connect(Act, SIGNAL(triggered()), this, SLOT(InsertWithSelectionFromAction()));
1874 math11Menu->addAction(Act);
1875 Act = new QAction("\\mathtt{} [selection]", this);
1876 Act->setData("\\mathtt{/}/8/0");
1877 connect(Act, SIGNAL(triggered()), this, SLOT(InsertWithSelectionFromAction()));
1878 math11Menu->addAction(Act);
1879 Act = new QAction("\\mathcal{} [selection]", this);
1880 Act->setData("\\mathcal{/}/9/0");
1881 connect(Act, SIGNAL(triggered()), this, SLOT(InsertWithSelectionFromAction()));
1882 math11Menu->addAction(Act);
1883 Act = new QAction("\\mathbb{} [selection]", this);
1884 Act->setData("\\mathbb{/}/8/0");
1885 connect(Act, SIGNAL(triggered()), this, SLOT(InsertWithSelectionFromAction()));
1886 math11Menu->addAction(Act);
1887 Act = new QAction("\\mathfrak{} [selection]", this);
1888 Act->setData("\\mathfrak{/}/10/0");
1889 connect(Act, SIGNAL(triggered()), this, SLOT(InsertWithSelectionFromAction()));
1890 math11Menu->addAction(Act);
1891
1892 math12Menu=math1Menu->addMenu(tr("Math &Accents"));
1893 Act = new QAction(getIcon(":/images/acute.png"),"\\acute{}", this);
1894 Act->setData("\\acute{}/7/0/ ");
1895 connect(Act, SIGNAL(triggered()), this, SLOT(InsertFromAction()));
1896 math12Menu->addAction(Act);
1897 Act = new QAction(getIcon(":/images/grave.png"),"\\grave{}", this);
1898 Act->setData("\\grave{}/7/0/ ");
1899 connect(Act, SIGNAL(triggered()), this, SLOT(InsertFromAction()));
1900 math12Menu->addAction(Act);
1901 Act = new QAction(getIcon(":/images/tilde.png"),"\\tilde{}", this);
1902 Act->setData("\\tilde{}/7/0/ ");
1903 connect(Act, SIGNAL(triggered()), this, SLOT(InsertFromAction()));
1904 math12Menu->addAction(Act);
1905 Act = new QAction(getIcon(":/images/bar.png"),"\\bar{}", this);
1906 Act->setData("\\bar{}/5/0/ ");
1907 connect(Act, SIGNAL(triggered()), this, SLOT(InsertFromAction()));
1908 math12Menu->addAction(Act);
1909 Act = new QAction(getIcon(":/images/vec.png"),"\\vec{}", this);
1910 Act->setData("\\vec{}/5/0/ ");
1911 connect(Act, SIGNAL(triggered()), this, SLOT(InsertFromAction()));
1912 math12Menu->addAction(Act);
1913 Act = new QAction(getIcon(":/images/hat.png"),"\\hat{}", this);
1914 Act->setData("\\hat{}/5/0/ ");
1915 connect(Act, SIGNAL(triggered()), this, SLOT(InsertFromAction()));
1916 math12Menu->addAction(Act);
1917 Act = new QAction(getIcon(":/images/check.png"),"\\check{}", this);
1918 Act->setData("\\check{}/7/0/ ");
1919 connect(Act, SIGNAL(triggered()), this, SLOT(InsertFromAction()));
1920 math12Menu->addAction(Act);
1921 Act = new QAction(getIcon(":/images/breve.png"),"\\breve{}", this);
1922 Act->setData("\\breve{}/7/0/ ");
1923 connect(Act, SIGNAL(triggered()), this, SLOT(InsertFromAction()));
1924 math12Menu->addAction(Act);
1925 Act = new QAction(getIcon(":/images/dot.png"),"\\dot{}", this);
1926 Act->setData("\\dot{}/5/0/ ");
1927 connect(Act, SIGNAL(triggered()), this, SLOT(InsertFromAction()));
1928 math12Menu->addAction(Act);
1929 Act = new QAction(getIcon(":/images/ddot.png"),"\\ddot{}", this);
1930 Act->setData("\\ddot{}/6/0/ ");
1931 connect(Act, SIGNAL(triggered()), this, SLOT(InsertFromAction()));
1932 math12Menu->addAction(Act);
1933
1934 math13Menu=math1Menu->addMenu(tr("Math S&paces"));
1935 Act = new QAction("small", this);
1936 Act->setData("\\,/2/0/ ");
1937 connect(Act, SIGNAL(triggered()), this, SLOT(InsertFromAction()));
1938 math13Menu->addAction(Act);
1939 Act = new QAction("medium", this);
1940 Act->setData("\\:/2/0/ ");
1941 connect(Act, SIGNAL(triggered()), this, SLOT(InsertFromAction()));
1942 math13Menu->addAction(Act);
1943 Act = new QAction("large", this);
1944 Act->setData("\\;/2/0/ ");
1945 connect(Act, SIGNAL(triggered()), this, SLOT(InsertFromAction()));
1946 math13Menu->addAction(Act);
1947 Act = new QAction("\\quad", this);
1948 Act->setData("\\quad/5/0/ ");
1949 connect(Act, SIGNAL(triggered()), this, SLOT(InsertFromAction()));
1950 math13Menu->addAction(Act);
1951 Act = new QAction("\\qquad", this);
1952 Act->setData("\\qquad/6/0/ ");
1953 connect(Act, SIGNAL(triggered()), this, SLOT(InsertFromAction()));
1954 math13Menu->addAction(Act);
1955
1956 wizardMenu = menuBar()->addMenu(tr("&Wizard"));
1957 Act = new QAction(tr("Quick Start"), this);
1958 connect(Act, SIGNAL(triggered()), this, SLOT(QuickDocument()));
1959 wizardMenu->addAction(Act);
1960 Act = new QAction(tr("Quick Beamer Presentation"), this);
1961 connect(Act, SIGNAL(triggered()), this, SLOT(QuickBeamer()));
1962 wizardMenu->addAction(Act);
1963 Act = new QAction(tr("Quick Xelatex Document"), this);
1964 connect(Act, SIGNAL(triggered()), this, SLOT(QuickXelatex()));
1965 wizardMenu->addAction(Act);
1966 Act = new QAction(tr("Quick Letter"), this);
1967 connect(Act, SIGNAL(triggered()), this, SLOT(QuickLetter()));
1968 wizardMenu->addAction(Act);
1969 wizardMenu->addSeparator();
1970 Act = new QAction(tr("Quick Tabular"), this);
1971 connect(Act, SIGNAL(triggered()), this, SLOT(QuickTabular()));
1972 wizardMenu->addAction(Act);
1973 Act = new QAction(tr("Quick Tabbing"), this);
1974 connect(Act, SIGNAL(triggered()), this, SLOT(QuickTabbing()));
1975 wizardMenu->addAction(Act);
1976 Act = new QAction(tr("Quick Array"), this);
1977 connect(Act, SIGNAL(triggered()), this, SLOT(QuickArray()));
1978 wizardMenu->addAction(Act);
1979
1980 bibMenu = menuBar()->addMenu(tr("&Bibliography"));
1981
1982 bibtexMenu=bibMenu->addMenu("Bibtex");
1983 Act = new QAction("Article in Journal", this);
1984 connect(Act, SIGNAL(triggered()), this, SLOT(InsertBib1()));
1985 bibtexMenu->addAction(Act);
1986 Act = new QAction("Article in Conference Proceedings", this);
1987 connect(Act, SIGNAL(triggered()), this, SLOT(InsertBib2()));
1988 bibtexMenu->addAction(Act);
1989 Act = new QAction("Article in a collection", this);
1990 connect(Act, SIGNAL(triggered()), this, SLOT(InsertBib3()));
1991 bibtexMenu->addAction(Act);
1992 Act = new QAction("Chapter or Pages in a Book", this);
1993 connect(Act, SIGNAL(triggered()), this, SLOT(InsertBib4()));
1994 bibtexMenu->addAction(Act);
1995 Act = new QAction("Conference Proceedings", this);
1996 connect(Act, SIGNAL(triggered()), this, SLOT(InsertBib5()));
1997 bibtexMenu->addAction(Act);
1998 Act = new QAction("Book", this);
1999 connect(Act, SIGNAL(triggered()), this, SLOT(InsertBib6()));
2000 bibtexMenu->addAction(Act);
2001 Act = new QAction("Booklet", this);
2002 connect(Act, SIGNAL(triggered()), this, SLOT(InsertBib7()));
2003 bibtexMenu->addAction(Act);
2004 Act = new QAction("PhD. Thesis", this);
2005 connect(Act, SIGNAL(triggered()), this, SLOT(InsertBib8()));
2006 bibtexMenu->addAction(Act);
2007 Act = new QAction("Master's Thesis", this);
2008 connect(Act, SIGNAL(triggered()), this, SLOT(InsertBib9()));
2009 bibtexMenu->addAction(Act);
2010 Act = new QAction("Technical Report", this);
2011 connect(Act, SIGNAL(triggered()), this, SLOT(InsertBib10()));
2012 bibtexMenu->addAction(Act);
2013 Act = new QAction("Technical Manual", this);
2014 connect(Act, SIGNAL(triggered()), this, SLOT(InsertBib11()));
2015 bibtexMenu->addAction(Act);
2016 Act = new QAction("Unpublished", this);
2017 connect(Act, SIGNAL(triggered()), this, SLOT(InsertBib12()));
2018 bibtexMenu->addAction(Act);
2019 Act = new QAction("Miscellaneous", this);
2020 connect(Act, SIGNAL(triggered()), this, SLOT(InsertBib13()));
2021 bibtexMenu->addAction(Act);
2022
2023
2024 biblatexMenu=bibMenu->addMenu("Biblatex");
2025 Act = new QAction("Article in Journal", this);
2026 connect(Act, SIGNAL(triggered()), this, SLOT(InsertBibLatex1()));
2027 biblatexMenu->addAction(Act);
2028 Act = new QAction("Single-volume book", this);
2029 connect(Act, SIGNAL(triggered()), this, SLOT(InsertBibLatex2()));
2030 biblatexMenu->addAction(Act);
2031 Act = new QAction("Multi-volume book", this);
2032 connect(Act, SIGNAL(triggered()), this, SLOT(InsertBibLatex3()));
2033 biblatexMenu->addAction(Act);
2034 Act = new QAction("Part of a book", this);
2035 connect(Act, SIGNAL(triggered()), this, SLOT(InsertBibLatex4()));
2036 biblatexMenu->addAction(Act);
2037 Act = new QAction("Booklet", this);
2038 connect(Act, SIGNAL(triggered()), this, SLOT(InsertBibLatex5()));
2039 biblatexMenu->addAction(Act);
2040 Act = new QAction("Single-volume collection", this);
2041 connect(Act, SIGNAL(triggered()), this, SLOT(InsertBibLatex6()));
2042 biblatexMenu->addAction(Act);
2043 Act = new QAction("Multi-volume collection", this);
2044 connect(Act, SIGNAL(triggered()), this, SLOT(InsertBibLatex7()));
2045 biblatexMenu->addAction(Act);
2046 Act = new QAction("Part of a collection", this);
2047 connect(Act, SIGNAL(triggered()), this, SLOT(InsertBibLatex8()));
2048 biblatexMenu->addAction(Act);
2049 Act = new QAction("Technical documentation", this);
2050 connect(Act, SIGNAL(triggered()), this, SLOT(InsertBibLatex9()));
2051 biblatexMenu->addAction(Act);
2052 Act = new QAction("Miscellaneous", this);
2053 connect(Act, SIGNAL(triggered()), this, SLOT(InsertBibLatex10()));
2054 biblatexMenu->addAction(Act);
2055 Act = new QAction("Online resource", this);
2056 connect(Act, SIGNAL(triggered()), this, SLOT(InsertBibLatex11()));
2057 biblatexMenu->addAction(Act);
2058 Act = new QAction("Issue of a periodical", this);
2059 connect(Act, SIGNAL(triggered()), this, SLOT(InsertBibLatex12()));
2060 biblatexMenu->addAction(Act);
2061 Act = new QAction("Single-volume conference proceedings", this);
2062 connect(Act, SIGNAL(triggered()), this, SLOT(InsertBibLatex13()));
2063 biblatexMenu->addAction(Act);
2064 Act = new QAction("Multi-volume conference proceedings", this);
2065 connect(Act, SIGNAL(triggered()), this, SLOT(InsertBibLatex14()));
2066 biblatexMenu->addAction(Act);
2067 Act = new QAction("Article in conference proceedings", this);
2068 connect(Act, SIGNAL(triggered()), this, SLOT(InsertBibLatex15()));
2069 biblatexMenu->addAction(Act);
2070 Act = new QAction("Technical report", this);
2071 connect(Act, SIGNAL(triggered()), this, SLOT(InsertBibLatex16()));
2072 biblatexMenu->addAction(Act);
2073 Act = new QAction("Thesis", this);
2074 connect(Act, SIGNAL(triggered()), this, SLOT(InsertBibLatex17()));
2075 biblatexMenu->addAction(Act);
2076 Act = new QAction("Patent", this);
2077 connect(Act, SIGNAL(triggered()), this, SLOT(InsertBibLatex18()));
2078 biblatexMenu->addAction(Act);
2079
2080 bibMenu->addSeparator();
2081 Act = new QAction(tr("Clean"), this);
2082 connect(Act, SIGNAL(triggered()), this, SLOT(CleanBib()));
2083 bibMenu->addAction(Act);
2084
2085
2086 user1Menu = menuBar()->addMenu(tr("&User"));
2087 user11Menu=user1Menu->addMenu(tr("User &Tags"));
2088 Act = new QAction("1: "+UserMenuName[0], this);
2089 Act->setShortcut(Qt::SHIFT+Qt::Key_F1);
2090 connect(Act, SIGNAL(triggered()), this, SLOT(InsertUserTag1()));
2091 user11Menu->addAction(Act);
2092 Act = new QAction("2: "+UserMenuName[1], this);
2093 Act->setShortcut(Qt::SHIFT+Qt::Key_F2);
2094 connect(Act, SIGNAL(triggered()), this, SLOT(InsertUserTag2()));
2095 user11Menu->addAction(Act);
2096 Act = new QAction("3: "+UserMenuName[2], this);
2097 Act->setShortcut(Qt::SHIFT+Qt::Key_F3);
2098 connect(Act, SIGNAL(triggered()), this, SLOT(InsertUserTag3()));
2099 user11Menu->addAction(Act);
2100 Act = new QAction("4: "+UserMenuName[3], this);
2101 Act->setShortcut(Qt::SHIFT+Qt::Key_F4);
2102 connect(Act, SIGNAL(triggered()), this, SLOT(InsertUserTag4()));
2103 user11Menu->addAction(Act);
2104 Act = new QAction("5: "+UserMenuName[4], this);
2105 Act->setShortcut(Qt::SHIFT+Qt::Key_F5);
2106 connect(Act, SIGNAL(triggered()), this, SLOT(InsertUserTag5()));
2107 user11Menu->addAction(Act);
2108 Act = new QAction("6: "+UserMenuName[5], this);
2109 Act->setShortcut(Qt::SHIFT+Qt::Key_F6);
2110 connect(Act, SIGNAL(triggered()), this, SLOT(InsertUserTag6()));
2111 user11Menu->addAction(Act);
2112 Act = new QAction("7: "+UserMenuName[6], this);
2113 Act->setShortcut(Qt::SHIFT+Qt::Key_F7);
2114 connect(Act, SIGNAL(triggered()), this, SLOT(InsertUserTag7()));
2115 user11Menu->addAction(Act);
2116 Act = new QAction("8: "+UserMenuName[7], this);
2117 Act->setShortcut(Qt::SHIFT+Qt::Key_F8);
2118 connect(Act, SIGNAL(triggered()), this, SLOT(InsertUserTag8()));
2119 user11Menu->addAction(Act);
2120 Act = new QAction("9: "+UserMenuName[8], this);
2121 Act->setShortcut(Qt::SHIFT+Qt::Key_F9);
2122 connect(Act, SIGNAL(triggered()), this, SLOT(InsertUserTag9()));
2123 user11Menu->addAction(Act);
2124 Act = new QAction("10: "+UserMenuName[9], this);
2125 Act->setShortcut(Qt::SHIFT+Qt::Key_F10);
2126 connect(Act, SIGNAL(triggered()), this, SLOT(InsertUserTag10()));
2127 user11Menu->addAction(Act);
2128 user11Menu->addSeparator();
2129 Act = new QAction(tr("Edit User &Tags"), this);
2130 connect(Act, SIGNAL(triggered()), this, SLOT(EditUserMenu()));
2131 user11Menu->addAction(Act);
2132 user12Menu=user1Menu->addMenu(tr("User &Commands"));
2133 Act = new QAction("1: "+UserToolName[0], this);
2134 Act->setShortcut(Qt::SHIFT+Qt::ALT+Qt::Key_F1);
2135 connect(Act, SIGNAL(triggered()), this, SLOT(UserTool1()));
2136 user12Menu->addAction(Act);
2137 Act = new QAction("2: "+UserToolName[1], this);
2138 Act->setShortcut(Qt::SHIFT+Qt::ALT+Qt::Key_F2);
2139 connect(Act, SIGNAL(triggered()), this, SLOT(UserTool2()));
2140 user12Menu->addAction(Act);
2141 Act = new QAction("3: "+UserToolName[2], this);
2142 Act->setShortcut(Qt::SHIFT+Qt::ALT+Qt::Key_F3);
2143 connect(Act, SIGNAL(triggered()), this, SLOT(UserTool3()));
2144 user12Menu->addAction(Act);
2145 Act = new QAction("4: "+UserToolName[3], this);
2146 Act->setShortcut(Qt::SHIFT+Qt::ALT+Qt::Key_F4);
2147 connect(Act, SIGNAL(triggered()), this, SLOT(UserTool4()));
2148 user12Menu->addAction(Act);
2149 Act = new QAction("5: "+UserToolName[4], this);
2150 Act->setShortcut(Qt::SHIFT+Qt::ALT+Qt::Key_F5);
2151 connect(Act, SIGNAL(triggered()), this, SLOT(UserTool5()));
2152 user12Menu->addAction(Act);
2153 user12Menu->addSeparator();
2154 Act = new QAction(tr("Edit User &Commands"), this);
2155 connect(Act, SIGNAL(triggered()), this, SLOT(EditUserTool()));
2156 user12Menu->addAction(Act);
2157
2158 Act = new QAction(tr("Customize Completion"), this);
2159 connect(Act, SIGNAL(triggered()), this, SLOT(EditUserCompletion()));
2160 user1Menu->addAction(Act);
2161
2162 user1Menu->addSeparator();
2163 scriptMenu=user1Menu->addMenu(tr("Run script"));
2164 for (int i=0; i < scriptList.count(); i++)
2165 {
2166 Act = new QAction(scriptList.at(i), this);
2167 Act->setData(scriptList.at(i)+".tms");
2168 connect(Act, SIGNAL(triggered()), this, SLOT(editRunFurnishedScript()));
2169 scriptMenu->addAction(Act);
2170 }
2171
2172
2173
2174 Act = new QAction(tr("Other script"), this);
2175 Act->setData("Other script");
2176 connect(Act, SIGNAL(triggered()), this, SLOT(editRunScript()));
2177 scriptMenu->addAction(Act);
2178
2179 viewMenu = menuBar()->addMenu(tr("&View"));
2180 NextDocAct = new QAction(tr("Next Document"), this);
2181 NextDocAct->setData("Next");
2182 NextDocAct->setShortcut(Qt::ALT+Qt::Key_PageDown);
2183 connect(NextDocAct, SIGNAL(triggered()), this, SLOT(gotoNextDocument()));
2184 viewMenu->addAction(NextDocAct);
2185 PrevDocAct = new QAction(tr("Previous Document"), this);
2186 PrevDocAct->setData("Prev");
2187 PrevDocAct->setShortcut(Qt::ALT+Qt::Key_PageUp);
2188 connect(PrevDocAct, SIGNAL(triggered()), this, SLOT(gotoPrevDocument()));
2189 viewMenu->addAction(PrevDocAct);
2190 viewMenu->addSeparator();
2191
2192 ViewStructurePanelAct = new QAction(tr("Structure"), this);
2193 ViewStructurePanelAct->setCheckable(true);
2194 connect(ViewStructurePanelAct, SIGNAL(triggered()), this, SLOT(ToggleStructurePanel()));
2195 ViewStructurePanelAct->setChecked(showstructview);
2196 viewMenu->addAction(ViewStructurePanelAct);
2197 ViewLogPanelAct = new QAction(tr("Messages / Log File"), this);
2198 ViewLogPanelAct->setCheckable(true);
2199 ViewLogPanelAct->setChecked(showoutputview);
2200 connect(ViewLogPanelAct, SIGNAL(triggered()), this, SLOT(ToggleLogPanel()));
2201 viewMenu->addAction(ViewLogPanelAct);
2202
2203 ViewPdfPanelAct = new QAction(tr("Pdf Viewer"), this);
2204 ViewPdfPanelAct->setCheckable(true);
2205 ViewPdfPanelAct->setChecked(showpdfview);
2206 connect(ViewPdfPanelAct, SIGNAL(triggered()), this, SLOT(TogglePdfPanel()));
2207 if (embedinternalpdf)
2208 {
2209 viewMenu->addAction(ViewPdfPanelAct);
2210 if (builtinpdfview) ViewPdfPanelAct->setEnabled(true);
2211 else ViewPdfPanelAct->setEnabled(false);
2212 }
2213
2214 ViewSourcePanelAct = new QAction("Source Viewer", this);
2215 ViewSourcePanelAct->setCheckable(true);
2216 ViewSourcePanelAct->setChecked(showsourceview);
2217 connect(ViewSourcePanelAct, SIGNAL(triggered()), this, SLOT(ToggleSourcePanel()));
2218 viewMenu->addAction(ViewSourcePanelAct);
2219
2220 ViewOpenedFilesPanelAct= new QAction(tr("List of opened files"), this);
2221 ViewOpenedFilesPanelAct->setCheckable(true);
2222 ViewOpenedFilesPanelAct->setChecked(showfilesview);
2223 connect(ViewOpenedFilesPanelAct, SIGNAL(triggered()), this, SLOT(ToggleFilesPanel()));
2224 viewMenu->addAction(ViewOpenedFilesPanelAct);
2225 viewMenu->addSeparator();
2226
2227 FullScreenAct = new QAction(tr("Full Screen"), this);
2228 FullScreenAct->setShortcut(Qt::CTRL+Qt::SHIFT+Qt::Key_F11);
2229 FullScreenAct->setCheckable(true);
2230 FullScreenAct->setChecked(false);
2231 connect(FullScreenAct, SIGNAL(triggered()), this, SLOT(ToggleFullScreen()));
2232 viewMenu->addAction(FullScreenAct);
2233
2234
2235 optionsMenu = menuBar()->addMenu(tr("&Options"));
2236 Act = new QAction(getIcon(":/images/configure.png"), tr("Configure Texmaker"), this);
2237 connect(Act, SIGNAL(triggered()), this, SLOT(GeneralOptions()));
2238 optionsMenu->addAction(Act);
2239 optionsMenu->addSeparator();
2240 ToggleAct = new QAction(tr("Define Current Document as 'Master Document'"), this);
2241 connect(ToggleAct, SIGNAL(triggered()), this, SLOT(ToggleMode()));
2242 optionsMenu->addAction(ToggleAct);
2243 optionsMenu->addSeparator();
2244 // appearanceMenu=optionsMenu->addMenu(tr("Interface Appearance"));
2245 // appearanceGroup = new QActionGroup(this);
2246 // Act = new QAction("Modern", this);
2247 // Act->setCheckable(true);
2248 // connect(Act, SIGNAL(triggered()), this, SLOT(updateAppearance()));
2249 // appearanceGroup->addAction(Act);
2250 // if (modern_style) Act->setChecked(true);
2251 // appearanceMenu->addAction(Act);
2252 // Act = new QAction("Classic", this);
2253 // Act->setCheckable(true);
2254 // connect(Act, SIGNAL(triggered()), this, SLOT(updateAppearance()));
2255 // appearanceGroup->addAction(Act);
2256 // if (!modern_style) Act->setChecked(true);
2257 // appearanceMenu->addAction(Act);
2258 #if defined(Q_OS_UNIX) && !defined(Q_OS_MAC)
2259 Act = new QAction(tr("Change Interface Font"), this);
2260 connect(Act, SIGNAL(triggered()), this, SLOT(SetInterfaceFont()));
2261 optionsMenu->addAction(Act);
2262 #endif
2263 optionsMenu->addSeparator();
2264 translationMenu=optionsMenu->addMenu(tr("Interface Language"));
2265 translationGroup = new QActionGroup(this);
2266 QString currentTranslation=TexmakerApp::instance()->language;
2267 for (int i=0; i < translationList.count(); i++)
2268 {
2269 Act = new QAction(translationList.at(i), this);
2270 Act->setCheckable(true);
2271 connect(Act, SIGNAL(triggered()), this, SLOT(updateTranslation()));
2272 translationGroup->addAction(Act);
2273 if ((currentTranslation==translationList.at(i)) || (currentTranslation.left(2)==translationList.at(i)) )
2274 {
2275 Act->setChecked(true);
2276 }
2277 translationMenu->addAction(Act);
2278 }
2279 optionsMenu->addSeparator();
2280 #if defined(Q_OS_MAC)
2281 settingsMenu=optionsMenu->addMenu(tr("Manage Settings File"));
2282 #else
2283 settingsMenu=optionsMenu->addMenu(tr("Settings File"));
2284 #endif
2285 Act = new QAction( tr("Reset Settings"), this);
2286 connect(Act, SIGNAL(triggered()), this, SLOT(DeleteSettings()));
2287 settingsMenu->addAction(Act);
2288 Act = new QAction( tr("Save a copy of the settings file"), this);
2289 connect(Act, SIGNAL(triggered()), this, SLOT(CopySettings()));
2290 settingsMenu->addAction(Act);
2291 Act = new QAction( tr("Replace the settings file by a new one"), this);
2292 connect(Act, SIGNAL(triggered()), this, SLOT(ReplaceSettings()));
2293 settingsMenu->addAction(Act);
2294
2295 helpMenu = menuBar()->addMenu(tr("&Help"));
2296 if (gtkEnv) Act = new QAction(QIcon::fromTheme("help-contents", QIcon(":/images/help.png")), tr("LaTeX Reference"), this);
2297 else Act = new QAction(getIcon(":/images/help.png"), tr("LaTeX Reference"), this);
2298 connect(Act, SIGNAL(triggered()), this, SLOT(LatexHelp()));
2299 helpMenu->addAction(Act);
2300 if (gtkEnv) Act = new QAction(QIcon::fromTheme("help-contents", QIcon(":/images/help.png")), tr("User Manual"), this);
2301 else Act = new QAction(getIcon(":/images/help.png"), tr("User Manual"), this);
2302 connect(Act, SIGNAL(triggered()), this, SLOT(UserManualHelp()));
2303 helpMenu->addAction(Act);
2304 helpMenu->addSeparator();
2305 if (gtkEnv) Act = new QAction(QIcon::fromTheme("help-contents", QIcon(":/images/help.png")), "TexDoc [selection]", this);
2306 else Act = new QAction(getIcon(":/images/help.png"), "TexDoc [selection]", this);
2307 connect(Act, SIGNAL(triggered()), this, SLOT(TexDocHelp()));
2308 helpMenu->addAction(Act);
2309
2310
2311 // QString locale = QString(QLocale::system().name()).left(2);
2312 // if (locale=="fr")
2313 // {
2314 // if (gtkEnv) Act = new QAction(QIcon::fromTheme("help-contents", QIcon(":/images/help.png")), QString::fromUtf8("Documentation LaTeX/Texmaker en ligne"), this);
2315 // else Act = new QAction(getIcon(":/images/help.png"), QString::fromUtf8("Documentation LaTeX/Texmaker en ligne"), this);
2316 // connect(Act, SIGNAL(triggered()), this, SLOT(Docufrlatex()));
2317 // helpMenu->addAction(Act);
2318 // }
2319 // else
2320 // {
2321 if (gtkEnv) Act = new QAction(QIcon::fromTheme("help-contents", QIcon(":/images/help.png")), QString::fromUtf8("LaTeX wikibook"), this);
2322 else Act = new QAction(getIcon(":/images/help.png"), QString::fromUtf8("LaTeX wikibook"), this);
2323 connect(Act, SIGNAL(triggered()), this, SLOT(Doculatex()));
2324 helpMenu->addAction(Act);
2325 //}
2326
2327 helpMenu->addSeparator();
2328 Act = new QAction( tr("Check for Update"), this);
2329 connect(Act, SIGNAL(triggered()), this, SLOT(CheckVersion()));
2330 helpMenu->addAction(Act);
2331
2332 helpMenu->addSeparator();
2333 Act = new QAction(getIcon(":/images/appicon.png"), tr("About Texmaker"), this);
2334 connect(Act, SIGNAL(triggered()), this, SLOT(HelpAbout()));
2335 helpMenu->addAction(Act);
2336
2337
2338 QList<QAction *> listaction;
2339 KeysMap::Iterator its;
2340 bool hasNextPrev=false;
2341 bool hasQuote=false;
2342 bool hasTools=false;
2343 bool hasEdit=false;
2344
2345 if (shortcuts.isEmpty())
2346 {
2347 actionstext.clear();
2348 listaction << toolMenu->actions();
2349 listaction << editMenu->actions();
2350 listaction << NextDocAct << PrevDocAct;
2351 listaction << latex1Menu->actions();
2352 listaction << latex11Menu->actions();
2353 listaction << latex12Menu->actions();
2354 listaction << latex13Menu->actions();
2355 listaction << latex14Menu->actions();
2356 listaction << latex15Menu->actions();
2357 listaction << latex16Menu->actions();
2358 listaction << latex17Menu->actions();
2359 listaction << latex18Menu->actions();
2360 listaction << math1Menu->actions();
2361 listaction << math11Menu->actions();
2362 listaction << math12Menu->actions();
2363 listaction << math13Menu->actions();
2364 listaction << math14Menu->actions();
2365 QListIterator<QAction*> iterator(listaction);
2366 while ( iterator.hasNext() )
2367 {
2368 QAction *action = iterator.next();
2369 if (action && (!action->menu()) && (!action->data().toString().isEmpty()))
2370 {
2371 if (action->shortcut().isEmpty()) shortcuts.insert(action->data().toString(),"none");
2372 else shortcuts.insert(action->data().toString(),action->shortcut().toString(QKeySequence::PortableText));
2373 actionstext.insert(action->data().toString(),action->text());
2374 }
2375 }
2376 }
2377 else
2378 {
2379 for( its = shortcuts.begin(); its != shortcuts.end(); ++its )
2380 {
2381 if (its.key()=="Next") hasNextPrev=true;
2382 if (its.key().contains("\\glqq / \\grqq")) hasQuote=true;
2383 if (its.key()=="LaTeX") hasTools=true;
2384 if (its.key()=="Comment") hasEdit=true;
2385 }
2386 if (!hasNextPrev)
2387 {
2388 shortcuts.insert(NextDocAct->data().toString(),NextDocAct->shortcut().toString(QKeySequence::PortableText));
2389 actionstext.insert(NextDocAct->data().toString(),NextDocAct->text());
2390 shortcuts.insert(PrevDocAct->data().toString(),PrevDocAct->shortcut().toString(QKeySequence::PortableText));
2391 actionstext.insert(PrevDocAct->data().toString(),PrevDocAct->text());
2392 }
2393 if (!hasQuote)
2394 {
2395 shortcuts.insert(latex18Menu->actions().at(0)->data().toString(),latex18Menu->actions().at(0)->shortcut().toString(QKeySequence::PortableText));
2396 actionstext.insert(latex18Menu->actions().at(0)->data().toString(),latex18Menu->actions().at(0)->text());
2397 shortcuts.insert(latex18Menu->actions().at(1)->data().toString(),latex18Menu->actions().at(1)->shortcut().toString(QKeySequence::PortableText));
2398 actionstext.insert(latex18Menu->actions().at(1)->data().toString(),latex18Menu->actions().at(1)->text());
2399 }
2400 if (!hasTools)
2401 {
2402 listaction << toolMenu->actions();
2403 QListIterator<QAction*> iterator(listaction);
2404 while ( iterator.hasNext() )
2405 {
2406 QAction *action = iterator.next();
2407 if (action && (!action->menu()) && (!action->data().toString().isEmpty()))
2408 {
2409 if (action->shortcut().isEmpty()) shortcuts.insert(action->data().toString(),"none");
2410 else shortcuts.insert(action->data().toString(),action->shortcut().toString(QKeySequence::PortableText));
2411 actionstext.insert(action->data().toString(),action->text());
2412 }
2413 }
2414 }
2415 listaction.clear();
2416 if (!hasEdit)
2417 {
2418 listaction << editMenu->actions();
2419 QListIterator<QAction*> iterator(listaction);
2420 while ( iterator.hasNext() )
2421 {
2422 QAction *action = iterator.next();
2423 if (action && (!action->menu()) && (!action->data().toString().isEmpty()))
2424 {
2425 if (action->shortcut().isEmpty()) shortcuts.insert(action->data().toString(),"none");
2426 else shortcuts.insert(action->data().toString(),action->shortcut().toString(QKeySequence::PortableText));
2427 actionstext.insert(action->data().toString(),action->text());
2428 }
2429 }
2430 }
2431 ModifyShortcuts();
2432 }
2433 }
2434
setupToolBars()2435 void Texmaker::setupToolBars()
2436 {
2437 QAction *Act;
2438 QStringList list;
2439 bool gtkEnv=false;
2440 //bool gtkEnv=gtkSession();
2441 //file
2442 fileToolBar = addToolBar("File ToolBar");
2443 fileToolBar->setObjectName("File");
2444 fileToolBar->setStyleSheet(Theme::viewportDarkStyleSheet);
2445
2446 if (gtkEnv) Act = new QAction(QIcon::fromTheme("document-new", QIcon(":/images/filenew.png")), tr("New"), this);
2447 else Act = new QAction(getIcon(":/images/filenew.png"), tr("New"), this);
2448 connect(Act, SIGNAL(triggered()), this, SLOT(fileNew()));
2449 fileToolBar->addAction(Act);
2450
2451 if (gtkEnv) Act = new QAction(QIcon::fromTheme("document-open", QIcon(":/images/fileopen.png")), tr("Open"), this);
2452 else Act = new QAction(getIcon(":/images/fileopen.png"), tr("Open"), this);
2453 connect(Act, SIGNAL(triggered()), this, SLOT(fileOpen()));
2454 fileToolBar->addAction(Act);
2455
2456 //Act = new QAction(QIcon(":/images/filesave.png"), tr("Save"), this);
2457 //connect(Act, SIGNAL(triggered()), this, SLOT(fileSave()));
2458 fileToolBar->addAction(SaveAct);
2459
2460 //Act = new QAction(QIcon(":/images/fileclose.png"), tr("Close"), this);
2461 //connect(Act, SIGNAL(triggered()), this, SLOT(fileClose()));
2462 //fileToolBar->addAction(Act);
2463
2464 //edit
2465 editToolBar = addToolBar("Edit ToolBar");
2466 editToolBar->setObjectName("Edit");
2467 editToolBar->setStyleSheet(Theme::viewportDarkStyleSheet);
2468
2469 //Act = new QAction(QIcon(":/images/undo.png"), tr("Undo"), this);
2470 //connect(Act, SIGNAL(triggered()), this, SLOT(editUndo()));
2471 editToolBar->addAction(UndoAct);
2472
2473 //Act = new QAction(QIcon(":/images/redo.png"), tr("Redo"), this);
2474 //connect(Act, SIGNAL(triggered()), this, SLOT(editRedo()));
2475 editToolBar->addAction(RedoAct);
2476
2477 //Act = new QAction(QIcon(":/images/editcopy.png"), tr("Copy"), this);
2478 //connect(Act, SIGNAL(triggered()), this, SLOT(editCopy()));
2479 editToolBar->addAction(CopyAct);
2480
2481 //Act = new QAction(QIcon(":/images/editcut.png"), tr("Cut"), this);
2482 //connect(Act, SIGNAL(triggered()), this, SLOT(editCut()));
2483 editToolBar->addAction(CutAct);
2484
2485 //Act = new QAction(QIcon(":/images/editpaste.png"), tr("Paste"), this);
2486 //connect(Act, SIGNAL(triggered()), this, SLOT(editPaste()));
2487 editToolBar->addAction(PasteAct);
2488
2489 //format
2490 //formatToolBar = addToolBar("Format ToolBar");
2491 //formatToolBar->setObjectName("Format");
2492 //insertToolBarBreak(formatToolBar);
2493
2494
2495 //tools
2496 runToolBar = addToolBar("Tools Toolbar");
2497 runToolBar->setObjectName("Tools");
2498 runToolBar->setStyleSheet(Theme::viewportDarkStyleSheet);
2499
2500 list.clear();
2501 list.append(tr("Quick Build"));
2502 list.append("LaTeX");
2503 list.append("Dvi->PS");
2504 list.append("PDFLaTeX");
2505 list.append("BibTeX");
2506 list.append("MakeIndex");
2507 list.append("MPost");
2508 list.append("PS->PDF");
2509 list.append("DVI->PDF");
2510 list.append("Asymptote");
2511 list.append("LatexMk");
2512 list.append("R Sweave");
2513 list.append("XeLaTeX");
2514 list.append("LuaLaTeX");
2515
2516 for ( int i = 0; i <= 4; i++ ) list.append(QString::number(i+1)+": "+UserToolName[i]);
2517
2518 comboCompil = new QComboBox(runToolBar);
2519 comboCompil->setSizePolicy(QSizePolicy::Minimum, QSizePolicy::Fixed);
2520 comboCompil->setStyleSheet(Theme::comboboxDarkStyleSheet);
2521 comboCompil->addItems(list);
2522 comboCompil->setCurrentIndex(runIndex);
2523 connect(runToolBar->addAction(getIcon(":/images/run.png"),tr("Run")), SIGNAL(triggered()), this, SLOT(doCompile()));
2524 runToolBar->addWidget(comboCompil);
2525
2526 list.clear();
2527 list.append(tr("View Dvi"));
2528 list.append(tr("View PS"));
2529 list.append(tr("View PDF"));
2530
2531 comboView = new QComboBox(runToolBar);
2532 comboView->setSizePolicy(QSizePolicy::Minimum, QSizePolicy::Fixed);
2533 comboView->setStyleSheet(Theme::comboboxDarkStyleSheet);
2534 comboView->addItems(list);
2535 comboView->setCurrentIndex(viewIndex);
2536 connect(runToolBar->addAction(getIcon(":/images/run.png"),tr("View")), SIGNAL(triggered()), this, SLOT(doView()));
2537 runToolBar->addWidget(comboView);
2538
2539
2540
2541 Act = new QAction(getIcon(":/images/viewlog.png"),tr("View Log"), this);
2542 connect(Act, SIGNAL(triggered()), this, SLOT(ViewLog()));
2543 logToolBar->addAction(Act);
2544
2545 Act = new QAction(getIcon(":/images/errornext.png"),tr("Next LaTeX Error"), this);
2546 connect(Act, SIGNAL(triggered()), this, SLOT(NextError()));
2547 Act->setShortcut(Qt::ALT+Qt::Key_Down);
2548 Act->setToolTip("Alt+Down");
2549 logToolBar->addAction(Act);
2550
2551 Act = new QAction(getIcon(":/images/errorprev.png"),tr("Previous LaTeX Error"), this);
2552 Act->setShortcut(Qt::ALT+Qt::Key_Up);
2553 Act->setToolTip("Alt+Up");
2554 connect(Act, SIGNAL(triggered()), this, SLOT(PreviousError()));
2555 logToolBar->addAction(Act);
2556
2557 StopAct = new QAction(getIcon(":/images/process-stop.png"),tr("Stop Process"), this);
2558 connect(StopAct, SIGNAL(triggered()), this, SLOT(stopProcess()));
2559 logToolBar->addAction(StopAct);
2560 StopAct->setEnabled(false);
2561
2562 viewMenu->addSeparator();
2563 viewMenu->addAction(fileToolBar->toggleViewAction());
2564 viewMenu->addAction(editToolBar->toggleViewAction());
2565 //viewMenu->addAction(formatToolBar->toggleViewAction());
2566 viewMenu->addAction(runToolBar->toggleViewAction());
2567 }
2568
2569
createStatusBar()2570 void Texmaker::createStatusBar()
2571 {
2572 toggleStructureButton=new PlayerButton(statusBar());
2573 toggleStructureButton->setImages("structure_button");
2574 connect(toggleStructureButton, SIGNAL( clicked() ), this, SLOT(ToggleStructurePanel() ) );
2575 statusBar()->addPermanentWidget(toggleStructureButton,0);
2576 toggleLogButton=new PlayerButton(statusBar());
2577 toggleLogButton->setImages("log_button");
2578 connect(toggleLogButton, SIGNAL( clicked() ), this, SLOT(ToggleLogPanel() ) );
2579 statusBar()->addPermanentWidget(toggleLogButton,0);
2580 togglePdfButton=new PlayerButton(statusBar());
2581 togglePdfButton->setImages("pdf_button");
2582 connect(togglePdfButton, SIGNAL( clicked() ), this, SLOT(TogglePdfPanel() ) );
2583 statusBar()->addPermanentWidget(togglePdfButton,0);
2584 toggleSourceButton=new PlayerButton(statusBar());
2585 toggleSourceButton->setImages("source_button");
2586 connect(toggleSourceButton, SIGNAL( clicked() ), this, SLOT(ToggleSourcePanel() ) );
2587 statusBar()->addPermanentWidget(toggleSourceButton,0);
2588
2589 if (embedinternalpdf && builtinpdfview) togglePdfButton->show();
2590 else togglePdfButton->hide();
2591
2592 stat2=new DropShadowLabel("Ready",statusBar());
2593 stat2->setColor(Theme::grayColor);
2594 stat2->setDropShadowColor(QColor("#000000"));
2595 stat2->setStyleSheet(Theme::labelStyleSheet);
2596 statusBar()->addPermanentWidget(stat2,0);
2597
2598 statusBar()->addPermanentWidget(new QLabel(),1);
2599
2600 stat1=new DropShadowLabel("",statusBar());
2601 stat1->setColor(Theme::grayColor);
2602 stat1->setDropShadowColor(QColor("#000000"));
2603 stat1->setStyleSheet(Theme::labelStyleSheet);
2604
2605 stat3=new DropShadowLabel("",statusBar());
2606 stat3->setColor(Theme::grayColor);
2607 stat3->setDropShadowColor(QColor("#000000"));
2608 stat3->setStyleSheet(Theme::labelStyleSheet);
2609
2610
2611 statusBar()->addPermanentWidget(stat3,0);
2612 statusBar()->addPermanentWidget(stat1,0);
2613 statusBar()->setAutoFillBackground( true );
2614 QPalette pal( palette() );
2615 pal.setColor( QPalette::Active, QPalette::WindowText,Theme::grayColor );
2616 pal.setColor( QPalette::Inactive, QPalette::WindowText, Theme::grayColor );
2617 pal.setColor( QPalette::Disabled, QPalette::WindowText, Theme::grayColor );
2618 pal.setColor( QPalette::Active, QPalette::HighlightedText, Theme::grayColor );
2619 pal.setColor( QPalette::Inactive, QPalette::HighlightedText, Theme::grayColor );
2620 pal.setColor( QPalette::Disabled, QPalette::HighlightedText,Theme::grayColor );
2621 pal.setColor( QPalette::Active, QPalette::Base, Theme::grayColor );
2622 pal.setColor( QPalette::Inactive, QPalette::Base, Theme::grayColor );
2623 pal.setColor( QPalette::Disabled, QPalette::Base, Theme::grayColor);
2624 pal.setColor(QPalette::Background, Theme::lightbackgroundColor);
2625 statusBar()->setPalette( pal );
2626 //statusBar()->setStyleSheet("QWidget {background-color:#6F6F6F;}");
2627
2628 toggleStructureButton->setEnabled(showstructview);
2629 toggleLogButton->setEnabled(showoutputview);
2630 togglePdfButton->setEnabled(showpdfview);
2631 toggleSourceButton->setEnabled(showsourceview);
2632 }
2633
UpdateCaption()2634 void Texmaker::UpdateCaption()
2635 {
2636 QString title;
2637 if ( !currentEditorView() ) {title="Texmaker";}
2638 else
2639 {
2640 title="Document : "+getName();
2641 //input_encoding=currentEditorView()->editor->getEncoding();
2642 }
2643 setWindowTitle(title);
2644 //UpdateStructure();
2645 if (singlemode)
2646 {
2647 OutputTextEdit->clear();
2648 OutputTableWidget->hide();
2649 if (splitter2->sizes().at(1)>0) OutputTextEdit->setMaximumHeight(splitter2->sizes().at(1));
2650 separatorline->hide();
2651 logpresent=false;
2652 }
2653 QString finame=getName();
2654 int check=comboFiles->findData(finame,Qt::UserRole,Qt::MatchExactly | Qt::MatchCaseSensitive);
2655 comboFiles->setCurrentIndex(check);
2656 if ((check>-1) && (check<OpenedFilesListWidget->count())) OpenedFilesListWidget->setCurrentRow(check);
2657 if (!finame.startsWith("untitled") && finame!="")
2658 {
2659 lastDocument=finame;
2660 }
2661 if (currentEditorView())
2662 {
2663 SaveAct->setEnabled(currentEditorView()->editor->document()->isModified());
2664 UndoAct->setEnabled(currentEditorView()->editor->document()->isUndoAvailable());
2665 RedoAct->setEnabled(currentEditorView()->editor->document()->isRedoAvailable());
2666 CopyAct->setEnabled(currentEditorView()->editor->textCursor().hasSelection());
2667 CutAct->setEnabled(currentEditorView()->editor->textCursor().hasSelection());
2668 stat3->setText(QString(" %1 ").arg(currentEditorView()->editor->getEncoding()));
2669 }
2670 else
2671 {
2672 SaveAct->setEnabled(false);
2673 UndoAct->setEnabled(false);
2674 RedoAct->setEnabled(false);
2675 CopyAct->setEnabled(false);
2676 CutAct->setEnabled(false);
2677 stat3->setText(QString(" %1 ").arg(input_encoding));
2678 }
2679 if (currentEditorView())
2680 {
2681 currentEditorView()->editor->setFocus();
2682 showCursorPos(currentEditorView()->editor->textCursor().blockNumber() + 1,currentEditorView()->editor->textCursor().position() - currentEditorView()->editor->textCursor().block().position()+1);
2683 // showCursorPos(currentEditorView()->editor->textCursor().blockNumber() + 1,currentEditorView()->editor->textCursor().position() - currentEditorView()->editor->document()->findBlock(currentEditorView()->editor->textCursor().selectionStart()).position());
2684 }
2685 else posLabel->setText("L: C: ");
2686 }
2687
NewDocumentStatus(bool m)2688 void Texmaker::NewDocumentStatus(bool m)
2689 {
2690 if ( !currentEditorView() ) return;
2691 QString finame=getName();
2692 int check=comboFiles->findData(finame,Qt::UserRole,Qt::MatchExactly | Qt::MatchCaseSensitive);
2693 if ((check>-1) && (check<OpenedFilesListWidget->count())) OpenedFilesListWidget->setCurrentRow(check);
2694 if (m)
2695 {
2696 //EditorView->setTabIcon(EditorView->indexOf(currentEditorView()),getIcon(":/images/modified.png"));
2697 //EditorView->setTabText(EditorView->indexOf(currentEditorView()),QFileInfo( getName() ).fileName());
2698 comboFiles->setItemIcon(comboFiles->findData(finame,Qt::UserRole,Qt::MatchExactly | Qt::MatchCaseSensitive),getIcon(":/images/modified.png"));
2699 if ((check>-1) && (check<OpenedFilesListWidget->count())) OpenedFilesListWidget->item(check)->setIcon(getIcon(":/images/modified.png"));
2700 SaveAct->setEnabled(true);
2701 }
2702 else
2703 {
2704 //EditorView->setTabIcon(EditorView->indexOf(currentEditorView()),getIcon(":/images/empty.png"));
2705 //EditorView->setTabText(EditorView->indexOf(currentEditorView()),QFileInfo( getName() ).fileName());
2706 currentEditorView()->editor->updateRevisions();
2707 comboFiles->setItemIcon(comboFiles->findData(finame,Qt::UserRole,Qt::MatchExactly | Qt::MatchCaseSensitive),QIcon(":/images/empty.png"));
2708 if ((check>-1) && (check<OpenedFilesListWidget->count())) OpenedFilesListWidget->item(check)->setIcon(QIcon(":/images/empty.png"));
2709 SaveAct->setEnabled(false);
2710 }
2711 }
2712
currentEditorView() const2713 LatexEditorView *Texmaker::currentEditorView() const
2714 {
2715 if ( EditorView->currentWidget() && EditorView->currentWidget()->inherits( "LatexEditorView" ) ) return (LatexEditorView*)EditorView->currentWidget();
2716 return 0;
2717 }
2718
getName()2719 QString Texmaker::getName()
2720 {
2721 QString title;
2722 if ( !currentEditorView() ) {title="";}
2723 else {title=filenames[currentEditorView()];}
2724 return title;
2725 }
2726
FileAlreadyOpen(QString f)2727 bool Texmaker::FileAlreadyOpen(QString f)
2728 {
2729 bool rep=false;
2730 FilesMap::Iterator it;
2731 QString fw32,funix,forig, canorig, can;
2732 canorig=QFileInfo(f).canonicalFilePath();
2733 for( it = filenames.begin(); it != filenames.end(); ++it )
2734 {
2735 forig=filenames[it.key()];
2736 fw32=filenames[it.key()];
2737 funix=filenames[it.key()];
2738 fw32.replace(QString("\\"),QString("/"));
2739 funix.replace(QString("/"),QString("\\"));
2740 can=QFileInfo(filenames[it.key()]).canonicalFilePath();
2741 if ( (forig==f) || (fw32==f) || (funix==f) || (canorig==can))
2742 {
2743 EditorView->setCurrentIndex(EditorView->indexOf(it.key()));
2744 rep=true;
2745 }
2746 }
2747 return rep;
2748 }
2749
ComboFilesInsert(const QString & file)2750 void Texmaker::ComboFilesInsert(const QString & file)
2751 {
2752 int index;
2753 QString fname = QFileInfo( file ).fileName();
2754
2755 for (index=0; index<comboFiles->count(); index++)
2756 if (comboFiles->itemText(index).localeAwareCompare(fname) > 0) break;
2757
2758 comboFiles->insertItem(index, fname, file);
2759 comboFiles->setItemIcon(index,QIcon(":/images/empty.png"));
2760 OpenedFilesListWidget->insertItem(index,fname);
2761 OpenedFilesListWidget->item(index)->setIcon(QIcon(":/images/empty.png"));
2762 }
2763 ///////////////////FILE//////////////////////////////////////
load(const QString & f)2764 void Texmaker::load( const QString &f )
2765 {
2766 if (FileAlreadyOpen(f) || !QFile::exists( f )) return;
2767 QFileInfo fi(f);
2768 if (fi.suffix()=="tks")
2769 {
2770 LoadSessionFile(f);
2771 return;
2772 }
2773
2774 QFile file( f );
2775 if ( !file.open( QIODevice::ReadOnly ) )
2776 {
2777 QMessageBox::warning( this,tr("Error"), tr("You do not have read permission to this file."));
2778 return;
2779 }
2780 bool hasDecodingError=false;
2781 QByteArray peekBytes(file.peek(1024));
2782 QByteArray buf = file.readAll();
2783
2784 int bytesRead = buf.size();
2785 file.close();
2786
2787 QTextCodec* detected_codec;
2788 QTextCodec* codec = QTextCodec::codecForName(input_encoding.toLatin1());
2789 if(!codec) codec = QTextCodec::codecForLocale();
2790
2791 QRegExp reEnc("% *!TEX +encoding *= *([^\\r\\n\\x2029]+)[\\r\\n\\x2029]", Qt::CaseInsensitive);
2792 int pos = reEnc.indexIn(codec->toUnicode(peekBytes));
2793 if (pos > -1)
2794 {
2795 QString reqName = reEnc.cap(1).trimmed();
2796 codec = QTextCodec::codecForName(reqName.toLatin1());
2797 if(!codec) codec = QTextCodec::codecForLocale();
2798 input_encoding=codec->name();
2799 }
2800
2801
2802 QString text = codec->toUnicode(buf);
2803 QByteArray verifyBuf = codec->fromUnicode(text);
2804 QString new_encoding="";
2805
2806 // unicode detection
2807 if (bytesRead >= 4 && ((uchar(buf[0]) == 0xff && uchar(buf[1]) == 0xfe && uchar(buf[2]) == 0 && uchar(buf[3]) == 0) || (uchar(buf[0]) == 0 && uchar(buf[1]) == 0 && uchar(buf[2]) == 0xfe && uchar(buf[3]) == 0xff)))
2808 {
2809 detected_codec = QTextCodec::codecForName("UTF-32");
2810 if (detected_codec) new_encoding=detected_codec->name();
2811 }
2812 else if (bytesRead >= 2 && ((uchar(buf[0]) == 0xff && uchar(buf[1]) == 0xfe) || (uchar(buf[0]) == 0xfe && uchar(buf[1]) == 0xff)))
2813 {
2814 detected_codec = QTextCodec::codecForName("UTF-16");
2815 if (detected_codec) new_encoding=detected_codec->name();
2816
2817 }
2818 else if (bytesRead >= 3 && uchar(buf[0]) == 0xef && uchar(buf[1]) == 0xbb && uchar(buf[2])== 0xbf)
2819 {
2820 detected_codec = QTextCodec::codecForName("UTF-8");
2821 if (detected_codec) new_encoding=detected_codec->name();
2822 }
2823 else
2824 {
2825 const char * data= buf.constData();
2826 int length=buf.size();
2827 bool canbeutf8=true;
2828 static const unsigned char highest1Bits = 0x80;
2829 static const unsigned char highest2Bits = 0xC0;
2830 static const unsigned char highest3Bits = 0xE0;
2831 static const unsigned char highest4Bits = 0xF0;
2832 static const unsigned char highest5Bits = 0xF8;
2833 int multiByte=0;
2834 for (int i=0; i<length; ++i)
2835 {
2836 unsigned char c = data[i];
2837
2838 if (multiByte>0)
2839 {
2840 if ((c & highest2Bits) == 0x80)
2841 {
2842 --(multiByte);
2843 continue;
2844 }
2845 canbeutf8=false;
2846 break;
2847 }
2848
2849 // most significant bit zero, single char
2850 if ((c & highest1Bits) == 0x00)
2851 continue;
2852
2853 // 110xxxxx => init 1 following bytes
2854 if ((c & highest3Bits) == 0xC0)
2855 {
2856 multiByte = 1;
2857 continue;
2858 }
2859
2860 // 1110xxxx => init 2 following bytes
2861 if ((c & highest4Bits) == 0xE0)
2862 {
2863 multiByte = 2;
2864 continue;
2865 }
2866
2867 // 11110xxx => init 3 following bytes
2868 if ((c & highest5Bits) == 0xF0)
2869 {
2870 multiByte = 3;
2871 continue;
2872 }
2873 canbeutf8=false;
2874 break;
2875 }
2876 if (canbeutf8)
2877 {
2878 detected_codec = QTextCodec::codecForName("UTF-8");
2879 if (detected_codec) new_encoding=detected_codec->name();
2880 }
2881 }
2882
2883 if (new_encoding!="")
2884 {
2885 if (new_encoding!=codec->name()) hasDecodingError=true;
2886 }
2887 else
2888 {
2889 // no unicode
2890 int minSize = qMin(verifyBuf.size(), buf.size());
2891 hasDecodingError = (minSize < buf.size()- 4 || memcmp(verifyBuf.constData() + verifyBuf.size() - minSize,buf.constData() + buf.size() - minSize, minSize));
2892 QEncodingProber prober (QEncodingProber::Universal);
2893 if (hasDecodingError)
2894 {
2895 prober.feed (buf.constData());
2896 if (prober.confidence() > 0.6) //Kencodingprober works very bad with tex documents
2897 {
2898 detected_codec = QTextCodec::codecForName(prober.encoding());
2899 if (detected_codec) new_encoding=detected_codec->name();
2900 else if (input_encoding=="UTF-8") new_encoding="ISO-8859-1";
2901 else if (input_encoding=="ISO-8859-1") new_encoding="UTF-8";
2902 else new_encoding=QString(QTextCodec::codecForLocale()->name());
2903 }
2904 else if (input_encoding=="UTF-8") new_encoding="ISO-8859-1";
2905 else if (input_encoding=="ISO-8859-1") new_encoding="UTF-8";
2906 else new_encoding=QString(QTextCodec::codecForLocale()->name());
2907 }
2908
2909 }
2910
2911
2912
2913 if (hasDecodingError)
2914 {
2915 EncodingDialog *encDlg = new EncodingDialog(this);
2916 encDlg->ui.comboBoxEncoding->setCurrentIndex(encDlg->ui.comboBoxEncoding->findText(new_encoding, Qt::MatchExactly));
2917 encDlg->ui.label->setText(encDlg->ui.label->text()+ " ("+input_encoding+").");
2918 if (encDlg->exec())
2919 {
2920 new_encoding=encDlg->ui.comboBoxEncoding->currentText();
2921 codec = QTextCodec::codecForName(new_encoding.toLatin1());
2922 text = codec->toUnicode(buf);
2923 }
2924 else return;
2925 }
2926
2927 #if defined(Q_OS_UNIX) && !defined(Q_OS_MAC)
2928
2929 #ifdef USB_VERSION
2930 QString dicDir=QCoreApplication::applicationDirPath() + "/";
2931 #else
2932 #ifdef DEBIAN_SPELLDIR
2933 QString dicDir=PREFIX"/share/myspell/dicts/";
2934 #else
2935 QString dicDir=PREFIX"/share/texmaker/";
2936 #endif
2937 #endif
2938
2939 #endif
2940 #if defined(Q_OS_MAC)
2941 QString dicDir=QCoreApplication::applicationDirPath() + "/../Resources/";
2942 #endif
2943 #if defined(Q_OS_WIN32)
2944 QString dicDir=QCoreApplication::applicationDirPath() + "/";
2945 #endif
2946 QRegExp reSpell("% *!TEX +spellcheck *= *([^\\r\\n\\x2029]+)[\\r\\n\\x2029]", Qt::CaseInsensitive);
2947 pos = reSpell.indexIn(codec->toUnicode(peekBytes));
2948 if (pos > -1)
2949 {
2950 QString lang = dicDir+reSpell.cap(1).trimmed();
2951 if (spellChecker) delete spellChecker;
2952 QString affdic=lang+".aff";
2953 QString spelldic=lang+".dic";
2954 QFileInfo fidic(spelldic);
2955 QFileInfo fiaff(affdic);
2956 if (fidic.exists() && fidic.isReadable() && fiaff.exists() && fiaff.isReadable())
2957 {
2958 spellChecker = new Hunspell(lang.toLatin1()+".aff",lang.toLatin1()+".dic");
2959 }
2960 else spellChecker=0;
2961 }
2962
2963 LatexEditorView *edit = new LatexEditorView(0,EditorFont,svnEnable,showline,edcolors(),hicolors(),inlinespellcheck,spell_ignored_words,spellChecker,tabspaces,tabwidth,QKeySequence(keyToggleFocus),f,userTagsList);
2964 EditorView->addWidget( edit);
2965 ComboFilesInsert(f);
2966 disconnect(EditorView, SIGNAL( currentChanged( int ) ), this, SLOT(UpdateStructure()) );
2967 EditorView->setCurrentIndex(EditorView->indexOf(edit));
2968 connect(EditorView, SIGNAL( currentChanged( int ) ), this, SLOT(UpdateStructure()) );
2969 edit->editor->setReadOnly(false);
2970 if (hasDecodingError) edit->editor->setEncoding(new_encoding);
2971 else edit->editor->setEncoding(input_encoding);
2972 initCompleter();
2973 if (completion) edit->editor->setCompleter(completer);
2974 else edit->editor->setCompleter(0);
2975 edit->editor->setPlainText(text);
2976 filenames.remove( edit);
2977 filenames.insert( edit, f );
2978
2979 edit->editor->resetRevisions();
2980 if(svnEnable)
2981 {
2982 connect(new SvnHelper(f,svnPath), SIGNAL(uncommittedLines(QList<int>)),edit->editor , SLOT(setUncommittedLines(QList<int>)));
2983 edit->editor->viewport()->update();
2984 }
2985
2986 edit->editor->document()->setModified(false);
2987 connect(edit->editor->document(), SIGNAL(modificationChanged(bool)), this, SLOT(NewDocumentStatus(bool)));
2988 connect(edit->editor, SIGNAL(spellme()), this, SLOT(editSpell()));
2989 connect(edit->editor, SIGNAL(tooltiptab()), this, SLOT(editTipTab()));
2990 connect(edit->editor, SIGNAL(requestpdf(int)),this, SLOT(jumpToPdfline(int)));
2991 connect(edit->editor, SIGNAL(requestUpdateStructure()), this, SLOT(UpdateStructure()));
2992 currentEditorView()->editor->setLastNumLines(currentEditorView()->editor->numoflines());
2993 connect(edit->editor, SIGNAL(numLinesChanged(int)), this, SLOT(refreshAllFromCursor(int)));
2994 connect(edit->editor->document(), SIGNAL(undoAvailable(bool)),UndoAct, SLOT(setEnabled(bool)));
2995 connect(edit->editor->document(), SIGNAL(redoAvailable(bool)),RedoAct, SLOT(setEnabled(bool)));
2996 connect(edit->editor, SIGNAL(copyAvailable(bool)), CutAct, SLOT(setEnabled(bool)));
2997 connect(edit->editor, SIGNAL(copyAvailable(bool)), CopyAct, SLOT(setEnabled(bool)));
2998 connect(edit->editor, SIGNAL(requestGotoStructure(int)),this, SLOT(jumpToStructure(int)));
2999 connect(edit->editor, SIGNAL(poshaschanged(int,int)),this, SLOT(showCursorPos(int,int)));
3000
3001 if (wordwrap) {edit->editor->setWordWrapMode(QTextOption::WordWrap);}
3002 else {edit->editor->setWordWrapMode(QTextOption::NoWrap);}
3003
3004
3005
3006 UpdateCaption();
3007 NewDocumentStatus(false);
3008 AddRecentFile(f);
3009 ShowStructure();
3010 UpdateStructure();
3011 UpdateBibliography();
3012
3013 QString rootName,rootFilePath;
3014 QTextCursor curs(edit->editor->document());
3015 curs.movePosition(QTextCursor::NextCharacter, QTextCursor::KeepAnchor,1024);
3016 QString peekStr = curs.selectedText();
3017 QRegExp re("% *!TEX +root *= *([^\\x2029]+)\\x2029", Qt::CaseInsensitive);
3018 pos = re.indexIn(peekStr);
3019 if (pos > -1)
3020 {
3021 rootName = re.cap(1).trimmed();
3022 QFileInfo rootFileInfo(fi.canonicalPath() + "/" + rootName);
3023 if (rootFileInfo.exists()) rootFilePath = rootFileInfo.canonicalFilePath();
3024 else rootFilePath = rootFileInfo.filePath();
3025 setMasterDocument(rootFilePath);
3026 }
3027
3028
3029
3030
3031 #if !defined(Q_OS_MAC)
3032 show();
3033 if (windowState()==Qt::WindowMinimized) setWindowState(windowState() & ~Qt::WindowMinimized | Qt::WindowActive);
3034 qApp->setActiveWindow(this);
3035 activateWindow();
3036 setFocus();
3037 //raise();
3038 //#ifdef Q_WS_WIN
3039 // if (IsIconic (this->winId())) ShowWindow(this->winId(), SW_RESTORE);
3040 //#endif
3041 #endif
3042 if (winmaximized) setWindowState(windowState() & Qt::WindowMaximized | Qt::WindowActive);
3043 edit->editor->setFocus();
3044 }
3045
setLine(const QString & line)3046 void Texmaker::setLine( const QString &line )
3047 {
3048 bool ok;
3049 int l=line.toInt(&ok,10);
3050 if (currentEditorView() && ok)
3051 {
3052 QTextCursor cur=currentEditorView()->editor->textCursor();
3053 cur.movePosition(QTextCursor::End);
3054 currentEditorView()->editor->setTextCursor(cur);
3055 currentEditorView()->editor->gotoLine(l-1);
3056 currentEditorView()->editor->setFocus();
3057 }
3058 }
3059
insertFromCommandLine(const QString & entity)3060 void Texmaker::insertFromCommandLine(const QString &entity)
3061 {
3062 if (currentEditorView())
3063 {
3064 currentEditorView()->editor->insertPlainText(entity);
3065 #if !defined(Q_OS_MAC)
3066 show();
3067 if (windowState()==Qt::WindowMinimized) setWindowState(windowState() & ~Qt::WindowMinimized | Qt::WindowActive);
3068 qApp->setActiveWindow(this);
3069 activateWindow();
3070 setFocus();
3071 #endif
3072 if (winmaximized) setWindowState(windowState() & Qt::WindowMaximized | Qt::WindowActive);
3073 currentEditorView()->editor->setFocus();
3074 }
3075 }
3076
fileNew()3077 void Texmaker::fileNew()
3078 {
3079 LatexEditorView *edit = new LatexEditorView(0,EditorFont,svnEnable,showline,edcolors(),hicolors(),inlinespellcheck,spell_ignored_words,spellChecker,tabspaces,tabwidth,QKeySequence(keyToggleFocus),"untitled"+QString::number(untitled_id),userTagsList);
3080 edit->editor->setReadOnly(false);
3081 edit->editor->setEncoding(input_encoding);
3082 initCompleter();
3083 if (completion) edit->editor->setCompleter(completer);
3084 else edit->editor->setCompleter(0);
3085 EditorView->addWidget( edit);
3086 EditorView->setCurrentIndex(EditorView->indexOf(edit));
3087 if (wordwrap) {edit->editor->setWordWrapMode(QTextOption::WordWrap);}
3088 else {edit->editor->setWordWrapMode(QTextOption::NoWrap);}
3089 filenames.remove( edit);
3090 filenames.insert( edit, "untitled"+QString::number(untitled_id) );
3091 ComboFilesInsert("untitled"+QString::number(untitled_id));
3092 untitled_id++;
3093 edit->editor->document()->setModified(false);
3094 connect(edit->editor->document(), SIGNAL(modificationChanged(bool)), this, SLOT(NewDocumentStatus(bool)));
3095 connect(edit->editor, SIGNAL(spellme()), this, SLOT(editSpell()));
3096 connect(edit->editor, SIGNAL(tooltiptab()), this, SLOT(editTipTab()));
3097 connect(edit->editor, SIGNAL(requestUpdateStructure()), this, SLOT(UpdateStructure()));
3098 connect(edit->editor, SIGNAL(requestpdf(int)),this, SLOT(jumpToPdfline(int)));
3099 currentEditorView()->editor->setLastNumLines(currentEditorView()->editor->numoflines());
3100 connect(edit->editor, SIGNAL(numLinesChanged(int)), this, SLOT(refreshAllFromCursor(int)));
3101 connect(edit->editor->document(), SIGNAL(undoAvailable(bool)),UndoAct, SLOT(setEnabled(bool)));
3102 connect(edit->editor->document(), SIGNAL(redoAvailable(bool)),RedoAct, SLOT(setEnabled(bool)));
3103 connect(edit->editor, SIGNAL(copyAvailable(bool)), CutAct, SLOT(setEnabled(bool)));
3104 connect(edit->editor, SIGNAL(copyAvailable(bool)), CopyAct, SLOT(setEnabled(bool)));
3105 connect(edit->editor, SIGNAL(requestGotoStructure(int)),this, SLOT(jumpToStructure(int)));
3106 connect(edit->editor, SIGNAL(poshaschanged(int,int)),this, SLOT(showCursorPos(int,int)));
3107 UpdateCaption();
3108 NewDocumentStatus(false);
3109 edit->editor->setFocus();
3110 }
3111
fileNewFromFile()3112 void Texmaker::fileNewFromFile()
3113 {
3114 QString currentDir=QDir::homePath();
3115 if (!lastTemplate.isEmpty())
3116 {
3117 QFileInfo fi(lastTemplate);
3118 if (fi.exists() && fi.isReadable()) currentDir=fi.absolutePath();
3119 }
3120 QString fn = QFileDialog::getOpenFileName(this,tr("Open File"),currentDir,"TeX files (*.tex *.bib *.sty *.cls *.mp *.Rnw *.asy);;All files (*.*)");
3121 if (fn.isEmpty()) return;
3122 QFile file( fn );
3123 if ( !file.open( QIODevice::ReadOnly ) )
3124 {
3125 QMessageBox::warning( this,tr("Error"), tr("You do not have read permission to this file."));
3126 return;
3127 }
3128 lastTemplate=fn;
3129 LatexEditorView *edit = new LatexEditorView(0,EditorFont,svnEnable,showline,edcolors(),hicolors(),inlinespellcheck,spell_ignored_words,spellChecker,tabspaces,tabwidth,QKeySequence(keyToggleFocus),fn,userTagsList);
3130 edit->editor->setReadOnly(false);
3131 edit->editor->setEncoding(input_encoding);
3132 initCompleter();
3133 if (completion) edit->editor->setCompleter(completer);
3134 else edit->editor->setCompleter(0);
3135 EditorView->addWidget( edit);
3136 EditorView->setCurrentIndex(EditorView->indexOf(edit));
3137 if (wordwrap) {edit->editor->setWordWrapMode(QTextOption::WordWrap);}
3138 else {edit->editor->setWordWrapMode(QTextOption::NoWrap);}
3139 filenames.remove( edit);
3140 filenames.insert( edit, "untitled"+QString::number(untitled_id));
3141 ComboFilesInsert("untitled"+QString::number(untitled_id));
3142 untitled_id++;
3143 QTextStream ts( &file );
3144 QTextCodec* codec = QTextCodec::codecForName(input_encoding.toLatin1());
3145 if(!codec) codec = QTextCodec::codecForLocale();
3146 ts.setCodec(codec);
3147 edit->editor->setPlainText( ts.readAll() );
3148 file.close();
3149 edit->editor->document()->setModified(true);
3150 connect(edit->editor->document(), SIGNAL(modificationChanged(bool)), this, SLOT(NewDocumentStatus(bool)));
3151 connect(edit->editor, SIGNAL(spellme()), this, SLOT(editSpell()));
3152 connect(edit->editor, SIGNAL(tooltiptab()), this, SLOT(editTipTab()));
3153 currentEditorView()->editor->setLastNumLines(currentEditorView()->editor->numoflines());
3154 connect(edit->editor, SIGNAL(numLinesChanged(int)), this, SLOT(refreshAllFromCursor(int)));
3155 connect(edit->editor, SIGNAL(requestpdf(int)),this, SLOT(jumpToPdfline(int)));
3156 connect(edit->editor, SIGNAL(requestUpdateStructure()), this, SLOT(UpdateStructure()));
3157 connect(edit->editor->document(), SIGNAL(undoAvailable(bool)),UndoAct, SLOT(setEnabled(bool)));
3158 connect(edit->editor->document(), SIGNAL(redoAvailable(bool)),RedoAct, SLOT(setEnabled(bool)));
3159 connect(edit->editor, SIGNAL(copyAvailable(bool)), CutAct, SLOT(setEnabled(bool)));
3160 connect(edit->editor, SIGNAL(copyAvailable(bool)), CopyAct, SLOT(setEnabled(bool)));
3161 connect(edit->editor, SIGNAL(requestGotoStructure(int)),this, SLOT(jumpToStructure(int)));
3162 connect(edit->editor, SIGNAL(poshaschanged(int,int)),this, SLOT(showCursorPos(int,int)));
3163
3164 UpdateCaption();
3165 NewDocumentStatus(true);
3166 UpdateStructure();
3167 UpdateBibliography();
3168 edit->editor->setFocus();
3169 }
3170
fileOpen()3171 void Texmaker::fileOpen()
3172 {
3173 QString currentDir=QDir::homePath();
3174 if (!lastDocument.isEmpty())
3175 {
3176 QFileInfo fi(lastDocument);
3177 if (fi.exists() && fi.isReadable()) currentDir=fi.absolutePath();
3178 }
3179 QStringList filesNames = QFileDialog::getOpenFileNames(this,tr("Open File"),currentDir,"TeX files (*.tex *.bib *.sty *.cls *.mp *.Rnw *.asy);;All files (*.*)");
3180 foreach (const QString& fn, filesNames)
3181 {
3182 if ( !fn.isEmpty() ) load( fn );
3183 }
3184 if ((filesNames.count()==1) && embedinternalpdf && builtinpdfview && showpdfview)
3185 {
3186 if ( !currentEditorView() || !singlemode ) return;
3187 QString finame=getName();
3188 QFileInfo fi(finame);
3189 QString basename=fi.completeBaseName();
3190 QString pdfname=outputName(finame,".pdf");
3191 QFileInfo pdfi(pdfname);
3192 if (pdfi.exists() && pdfi.isReadable())
3193 {
3194 if (pdfviewerWidget)
3195 {
3196 pdfviewerWidget->openFile(outputName(finame,".pdf"),viewpdf_command,ghostscript_command);
3197 StackedViewers->setCurrentWidget(pdfviewerWidget);
3198
3199 //pdfviewerWidget->raise();
3200 pdfviewerWidget->show();
3201 }
3202 else
3203 {
3204 // pdfviewerWidget=new PdfViewer(outputName(finame,".pdf"),viewpdf_command, this);
3205 pdfviewerWidget=new PdfViewerWidget(outputName(finame,".pdf"),viewpdf_command,ghostscript_command,lp_options,QKeySequence(keyToggleFocus),pdfCheckerLang,lastScale,StackedViewers);
3206 pdfviewerWidget->centralToolBarBis->setMinimumHeight(centralToolBarBis->height());
3207 pdfviewerWidget->centralToolBarBis->setMaximumHeight(centralToolBarBis->height());
3208 connect(pdfviewerWidget, SIGNAL(openDocAtLine(const QString&, int, bool)), this, SLOT(fileOpenAndGoto(const QString&, int, bool)));
3209 connect(pdfviewerWidget, SIGNAL(sendFocusToEditor()), this, SLOT(getFocusToEditor()));
3210 connect(pdfviewerWidget, SIGNAL(sendPaperSize(const QString&)), this, SLOT(setPrintPaperSize(const QString&)));
3211 StackedViewers->addWidget(pdfviewerWidget);
3212 StackedViewers->setCurrentWidget(pdfviewerWidget);
3213 //pdfviewerWidget->raise();
3214 pdfviewerWidget->show();
3215 pdfviewerWidget->openFile(outputName(finame,".pdf"),viewpdf_command,ghostscript_command);
3216 }
3217 }
3218 }
3219 if (currentEditorView()) currentEditorView()->editor->setFocus();
3220 }
3221
isCurrentModifiedOutside()3222 bool Texmaker::isCurrentModifiedOutside()
3223 {
3224 if ( !currentEditorView() ) return false;
3225 QString fn=*filenames.find( currentEditorView() );
3226 QFileInfo fi(fn);
3227 fi.refresh();
3228 QDateTime disktime=fi.lastModified();
3229 int delta=disktime.secsTo(currentEditorView()->editor->getLastSavedTime());
3230 if (watchfiles && (delta<-3)) return true;
3231 else return false;
3232 }
3233
checkModifiedOutsideAll()3234 void Texmaker::checkModifiedOutsideAll()
3235 {
3236 if (QApplication::activeWindow() != this) return;
3237
3238 QList<QTreeWidgetItem *> fItems;
3239 bool islabels_expanded=false;
3240 bool isblocks_expanded=true;
3241 fItems=StructureTreeWidget->findItems ("LABELS",Qt::MatchRecursive,0);
3242 if (fItems.size()>0 )
3243 {
3244 if (fItems.at(0))
3245 {
3246 islabels_expanded=fItems.at(0)->isExpanded();
3247 }
3248 }
3249 fItems.clear();
3250 fItems=StructureTreeWidget->findItems ("BLOCKS",Qt::MatchRecursive,0);
3251 if (fItems.size()>0 )
3252 {
3253 if (fItems.at(0))
3254 {
3255 isblocks_expanded=fItems.at(0)->isExpanded();
3256 }
3257 }
3258 LatexEditorView *temp = new LatexEditorView(EditorView,EditorFont,svnEnable,showline,edcolors(),hicolors(),inlinespellcheck,spell_ignored_words,spellChecker,tabspaces,tabwidth,QKeySequence(keyToggleFocus),getName(),userTagsList);
3259 temp=currentEditorView();
3260 FilesMap::Iterator it;
3261 QString fn;
3262 int choice;
3263 disconnect(EditorView, SIGNAL( currentChanged( int ) ), this, SLOT(UpdateStructure()) ); //*******
3264 for( it = filenames.begin(); it != filenames.end(); ++it )
3265 {
3266 EditorView->setCurrentIndex(EditorView->indexOf(it.key()));
3267 if ( !getName().startsWith("untitled"))
3268 {
3269 fn=*filenames.find( currentEditorView() );
3270 if (isCurrentModifiedOutside())
3271 {
3272 QFileInfo fi(fn);
3273 choice= QMessageBox::warning(this, "Texmaker",
3274 tr("The document has been changed outside Texmaker."
3275 "Do you want to reload it (and discard your changes) or save it (and overwrite the file)?"),
3276 tr("Reload the file"), tr("Save"), tr("Cancel"),
3277 0,
3278 2 );
3279 if (choice==0)
3280 {
3281 if (fi.exists() && fi.isReadable())
3282 {
3283 QFile file( fn );
3284 if (file.open( QIODevice::ReadOnly ) )
3285 {
3286 QApplication::setOverrideCursor(QCursor(Qt::WaitCursor));
3287 QTextStream ts( &file );
3288 QTextCodec* codec = QTextCodec::codecForName(currentEditorView()->editor->getEncoding().toLatin1());
3289 ts.setCodec(codec ? codec : QTextCodec::codecForLocale());
3290 disconnect(currentEditorView()->editor->document(), SIGNAL(modificationChanged(bool)), this, SLOT(NewDocumentStatus(bool)));
3291 disconnect(currentEditorView()->editor, SIGNAL(spellme()), this, SLOT(editSpell()));
3292 disconnect(currentEditorView()->editor, SIGNAL(tooltiptab()), this, SLOT(editTipTab()));
3293 disconnect(currentEditorView()->editor, SIGNAL(requestUpdateStructure()), this, SLOT(UpdateStructure()));
3294 disconnect(currentEditorView()->editor, SIGNAL(requestpdf(int)),this, SLOT(jumpToPdfline(int)));
3295 disconnect(currentEditorView()->editor->document(), SIGNAL(undoAvailable(bool)),UndoAct, SLOT(setEnabled(bool)));
3296 disconnect(currentEditorView()->editor->document(), SIGNAL(redoAvailable(bool)),RedoAct, SLOT(setEnabled(bool)));
3297 disconnect(currentEditorView()->editor, SIGNAL(copyAvailable(bool)), CutAct, SLOT(setEnabled(bool)));
3298 disconnect(currentEditorView()->editor, SIGNAL(copyAvailable(bool)), CopyAct, SLOT(setEnabled(bool)));
3299 disconnect(currentEditorView()->editor, SIGNAL(numLinesChanged(int)), this, SLOT(refreshAllFromCursor(int)));
3300 disconnect(currentEditorView()->editor, SIGNAL(requestGotoStructure(int)),this, SLOT(jumpToStructure(int)));
3301 disconnect(currentEditorView()->editor, SIGNAL(poshaschanged(int,int)),this, SLOT(showCursorPos(int,int)));
3302 currentEditorView()->editor->setPlainText( ts.readAll() );
3303 file.close();
3304 currentEditorView()->editor->setLastSavedTime(QDateTime::currentDateTime());
3305 connect(currentEditorView()->editor->document(), SIGNAL(modificationChanged(bool)), this, SLOT(NewDocumentStatus(bool)));
3306 connect(currentEditorView()->editor, SIGNAL(spellme()), this, SLOT(editSpell()));
3307 connect(currentEditorView()->editor, SIGNAL(tooltiptab()), this, SLOT(editTipTab()));
3308 connect(currentEditorView()->editor, SIGNAL(requestUpdateStructure()), this, SLOT(UpdateStructure()));
3309 connect(currentEditorView()->editor, SIGNAL(requestpdf(int)),this, SLOT(jumpToPdfline(int)));
3310 connect(currentEditorView()->editor->document(), SIGNAL(undoAvailable(bool)),UndoAct, SLOT(setEnabled(bool)));
3311 connect(currentEditorView()->editor->document(), SIGNAL(redoAvailable(bool)),RedoAct, SLOT(setEnabled(bool)));
3312 connect(currentEditorView()->editor, SIGNAL(copyAvailable(bool)), CutAct, SLOT(setEnabled(bool)));
3313 connect(currentEditorView()->editor, SIGNAL(copyAvailable(bool)), CopyAct, SLOT(setEnabled(bool)));
3314 currentEditorView()->editor->setLastNumLines(currentEditorView()->editor->numoflines());
3315 connect(currentEditorView()->editor, SIGNAL(numLinesChanged(int)), this, SLOT(refreshAllFromCursor(int)));
3316 connect(currentEditorView()->editor, SIGNAL(requestGotoStructure(int)),this, SLOT(jumpToStructure(int)));
3317 connect(currentEditorView()->editor, SIGNAL(poshaschanged(int,int)),this, SLOT(showCursorPos(int,int)));
3318 UpdateStructure();
3319 UpdateBibliography();
3320 QApplication::restoreOverrideCursor();
3321 }
3322 }
3323 }
3324 else if (choice==1)
3325 {
3326 QFile file(fn);
3327 if (file.open( QIODevice::WriteOnly ) )
3328 {
3329 QTextStream ts( &file );
3330 QTextCodec* codec = QTextCodec::codecForName(currentEditorView()->editor->getEncoding().toLatin1());
3331 ts.setCodec(codec ? codec : QTextCodec::codecForLocale());
3332 ts << currentEditorView()->editor->toPlainText();
3333 file.close();
3334 currentEditorView()->editor->setLastSavedTime(QDateTime::currentDateTime());
3335 currentEditorView()->editor->document()->setModified(false);
3336 }
3337 }
3338 else currentEditorView()->editor->setLastSavedTime(QDateTime::currentDateTime());
3339 }
3340 }
3341 }
3342
3343 EditorView->setCurrentIndex(EditorView->indexOf(temp));
3344 connect(EditorView, SIGNAL( currentChanged( int ) ), this, SLOT(UpdateStructure()) ); //********
3345 QString title;
3346 if ( !currentEditorView() ) {title="Texmaker";}
3347 else
3348 {
3349 title="Document : "+getName();
3350 //input_encoding=currentEditorView()->editor->getEncoding();
3351 }
3352 setWindowTitle(title);
3353
3354 UpdateStructure();
3355 fItems.clear();
3356 fItems=StructureTreeWidget->findItems ("LABELS",Qt::MatchRecursive,0);
3357 if (fItems.size()>0 )
3358 {
3359 if (fItems.at(0))
3360 {
3361 StructureTreeWidget->setItemExpanded(fItems.at(0),islabels_expanded);
3362 }
3363 }
3364 fItems.clear();
3365 fItems=StructureTreeWidget->findItems ("BLOCKS",Qt::MatchRecursive,0);
3366 if (fItems.size()>0 )
3367 {
3368 if (fItems.at(0))
3369 {
3370 StructureTreeWidget->setItemExpanded (fItems.at(0),isblocks_expanded);
3371 }
3372 }
3373
3374 QString finame=getName();
3375 int check=comboFiles->findData(finame,Qt::UserRole,Qt::MatchExactly | Qt::MatchCaseSensitive);
3376 comboFiles->setCurrentIndex(check);
3377 if ((check>-1) && (check<OpenedFilesListWidget->count())) OpenedFilesListWidget->setCurrentRow(check);
3378
3379
3380 if (!finame.startsWith("untitled") && finame!="")
3381 {
3382 lastDocument=finame;
3383
3384 }
3385 if (currentEditorView())
3386 {
3387 SaveAct->setEnabled(currentEditorView()->editor->document()->isModified());
3388 UndoAct->setEnabled(currentEditorView()->editor->document()->isUndoAvailable());
3389 RedoAct->setEnabled(currentEditorView()->editor->document()->isRedoAvailable());
3390 CopyAct->setEnabled(currentEditorView()->editor->textCursor().hasSelection());
3391 CutAct->setEnabled(currentEditorView()->editor->textCursor().hasSelection());
3392 stat3->setText(QString(" %1 ").arg(currentEditorView()->editor->getEncoding()));
3393 }
3394 else
3395 {
3396 SaveAct->setEnabled(false);
3397 UndoAct->setEnabled(false);
3398 RedoAct->setEnabled(false);
3399 CopyAct->setEnabled(false);
3400 CutAct->setEnabled(false);
3401 }
3402 if (currentEditorView()) currentEditorView()->editor->setFocus();
3403 }
3404
fileSave()3405 void Texmaker::fileSave()
3406 {
3407 if ( !currentEditorView() ) return;
3408 QString fn;
3409 if ( getName().startsWith("untitled") ) {fileSaveAs();}
3410 else
3411 {
3412 fn=*filenames.find( currentEditorView() );
3413 if (isCurrentModifiedOutside())
3414 {
3415 QFileInfo fi(fn);
3416 switch( QMessageBox::warning(this, "Texmaker",
3417 tr("The document has been changed outside Texmaker."
3418 "Do you want to reload it (and discard your changes) or save it (and overwrite the file)?"),
3419 tr("Reload the file"), tr("Save"), tr("Cancel"),
3420 0,
3421 2 ) )
3422 {
3423 case 0:
3424 if (fi.exists() && fi.isReadable())
3425 {
3426 filenames.remove(currentEditorView());
3427 comboFiles->removeItem(comboFiles->currentIndex());
3428 delete OpenedFilesListWidget->currentItem();
3429 delete currentEditorView();
3430 load(fn);
3431 return;
3432 }
3433 break;
3434 case 1:
3435 break;
3436 case 2:
3437 default:
3438 currentEditorView()->editor->setLastSavedTime(QDateTime::currentDateTime());
3439 return;
3440 break;
3441 }
3442 }
3443 QFile file(fn);
3444 if ( !file.open( QIODevice::WriteOnly ) )
3445 {
3446 QMessageBox::warning( this,tr("Error"),tr("The file could not be saved. Please check if you have write permission."));
3447 return;
3448 }
3449 QTextStream ts( &file );
3450 QTextCodec* codec = QTextCodec::codecForName(currentEditorView()->editor->getEncoding().toLatin1());
3451 ts.setCodec(codec ? codec : QTextCodec::codecForLocale());
3452 ts << currentEditorView()->editor->toPlainText();
3453 file.close();
3454 currentEditorView()->editor->setLastSavedTime(QDateTime::currentDateTime());
3455 currentEditorView()->editor->document()->setModified(false);
3456 fn=getName();
3457 AddRecentFile(fn);
3458 }
3459 UpdateCaption();
3460 }
3461
currentfileSaved()3462 bool Texmaker::currentfileSaved()
3463 {
3464 if ( !currentEditorView() ) return true;
3465 QString fn;
3466 if ( getName().startsWith("untitled") ) {return false;}
3467 else
3468 {
3469 fn=*filenames.find( currentEditorView() );
3470 if (isCurrentModifiedOutside())
3471 {
3472 QFileInfo fi(fn);
3473 switch( QMessageBox::warning(this, "Texmaker",
3474 tr("The document has been changed outside Texmaker."
3475 "Do you want to reload it (and discard your changes) or save it (and overwrite the file)?"),
3476 tr("Reload the file"), tr("Save"), tr("Cancel"),
3477 0,
3478 2 ) )
3479 {
3480 case 0:
3481 if (fi.exists() && fi.isReadable())
3482 {
3483 filenames.remove(currentEditorView());
3484 comboFiles->removeItem(comboFiles->currentIndex());
3485 delete OpenedFilesListWidget->currentItem();
3486 delete currentEditorView();
3487 load(fn);
3488 return true;
3489 }
3490 break;
3491 case 1:
3492 break;
3493 case 2:
3494 default:
3495 currentEditorView()->editor->setLastSavedTime(QDateTime::currentDateTime());
3496 return false;
3497 break;
3498 }
3499 }
3500 QFile file(fn);
3501 if ( !file.open( QIODevice::WriteOnly ) )
3502 {
3503 if (currentEditorView()->editor->document()->isModified())
3504 {
3505 QMessageBox::warning( this,tr("Error"),tr("The file could not be saved. Please check if you have write permission."));
3506 return false;
3507 }
3508 else return true;
3509 }
3510 QTextStream ts( &file );
3511 QTextCodec* codec = QTextCodec::codecForName(currentEditorView()->editor->getEncoding().toLatin1());
3512 ts.setCodec(codec ? codec : QTextCodec::codecForLocale());
3513 ts << currentEditorView()->editor->toPlainText();
3514 file.close();
3515 currentEditorView()->editor->setLastSavedTime(QDateTime::currentDateTime());
3516 currentEditorView()->editor->document()->setModified(false);
3517 fn=getName();
3518 AddRecentFile(fn);
3519 UpdateCaption();
3520 return true;
3521 }
3522 }
3523
fileSaveAs()3524 void Texmaker::fileSaveAs()
3525 {
3526 if ( !currentEditorView() ) return;
3527 QString currentDir=QDir::homePath();
3528 if (!lastDocument.isEmpty())
3529 {
3530 QFileInfo fi(lastDocument);
3531 if (fi.exists() && fi.isReadable()) currentDir=fi.absolutePath();
3532 }
3533 QString fn = QFileDialog::getSaveFileName(this,tr("Save As"),currentDir,"TeX files (*.tex *.bib *.sty *.cls *.mp *.Rnw *.asy);;All files (*.*)");
3534 if ( !fn.isEmpty() )
3535 {
3536 if (!fn.contains('.')) fn += ".tex";
3537 QFileInfo fic(fn);
3538 filenames.remove(currentEditorView());
3539 comboFiles->removeItem(comboFiles->currentIndex());
3540 delete OpenedFilesListWidget->currentItem();
3541 filenames.insert(currentEditorView(), fn );
3542 fileSave();
3543 currentEditorView()->editor->updateName(fn);
3544 //EditorView->setTabText(EditorView->indexOf(currentEditorView()),fic.fileName());
3545 ComboFilesInsert(fn);
3546 }
3547 UpdateCaption();
3548 }
3549
fileSaveAll()3550 void Texmaker::fileSaveAll()
3551 {
3552 LatexEditorView *temp = new LatexEditorView(EditorView,EditorFont,svnEnable,showline,edcolors(),hicolors(),inlinespellcheck,spell_ignored_words,spellChecker,tabspaces,tabwidth,QKeySequence(keyToggleFocus),getName(),userTagsList);
3553 temp=currentEditorView();
3554 FilesMap::Iterator it;
3555 for( it = filenames.begin(); it != filenames.end(); ++it )
3556 {
3557 EditorView->setCurrentIndex(EditorView->indexOf(it.key()));
3558 fileSave();
3559 }
3560 EditorView->setCurrentIndex(EditorView->indexOf(temp));
3561 UpdateCaption();
3562 }
3563
fileBackupAll()3564 void Texmaker::fileBackupAll()
3565 {
3566 if (!currentEditorView() ) return;
3567 QApplication::setOverrideCursor(QCursor(Qt::WaitCursor));
3568 LatexEditorView *temp = new LatexEditorView(EditorView,EditorFont,svnEnable,showline,edcolors(),hicolors(),inlinespellcheck,spell_ignored_words,spellChecker,tabspaces,tabwidth,QKeySequence(keyToggleFocus),getName(),userTagsList);
3569 temp=currentEditorView();
3570 QString fn;
3571 FilesMap::Iterator it;
3572 for( it = filenames.begin(); it != filenames.end(); ++it )
3573 {
3574 EditorView->setCurrentIndex(EditorView->indexOf(it.key()));
3575 if (currentEditorView() && !getName().startsWith("untitled"))
3576 {
3577 fn=*filenames.find( currentEditorView() )+".bak";
3578 QFile file(fn);
3579 if ( !file.open( QIODevice::WriteOnly ) ) continue;
3580 else
3581 {
3582 QTextStream ts( &file );
3583 QTextCodec* codec = QTextCodec::codecForName(currentEditorView()->editor->getEncoding().toLatin1());
3584 ts.setCodec(codec ? codec : QTextCodec::codecForLocale());
3585 ts << currentEditorView()->editor->toPlainText();
3586 file.close();
3587 }
3588 }
3589 }
3590 EditorView->setCurrentIndex(EditorView->indexOf(temp));
3591 UpdateCaption();
3592 QApplication::restoreOverrideCursor();
3593 }
3594
fileSaveACopy()3595 void Texmaker::fileSaveACopy()
3596 {
3597 if (!currentEditorView() ) return;
3598 QString currentDir=QDir::homePath();
3599 if (!lastDocument.isEmpty())
3600 {
3601 QFileInfo fi(lastDocument);
3602 if (fi.exists() && fi.isReadable()) currentDir=fi.absolutePath();
3603 }
3604 QString fn = QFileDialog::getSaveFileName(this,tr("Save As"),currentDir,"TeX files (*.tex *.bib *.sty *.cls *.mp *.Rnw *.asy);;All files (*.*)");
3605 if ( !fn.isEmpty() )
3606 {
3607 if (!fn.contains('.')) fn += ".tex";
3608 QFile file(fn);
3609 if ( file.open( QIODevice::WriteOnly ) )
3610 {
3611 QTextStream ts( &file );
3612 QTextCodec* codec = QTextCodec::codecForName(currentEditorView()->editor->getEncoding().toLatin1());
3613 ts.setCodec(codec ? codec : QTextCodec::codecForLocale());
3614 ts << currentEditorView()->editor->toPlainText();
3615 file.close();
3616 }
3617 }
3618 }
3619
fileClose()3620 void Texmaker::fileClose()
3621 {
3622 if ( !currentEditorView() ) return;
3623 if (currentEditorView()->editor->document()->isModified())
3624 {
3625 int query;
3626 QString locale = TexmakerApp::instance()->language.left(2);
3627 if (locale=="en")
3628 {
3629 query=QMessageBox::warning(this, "Texmaker",
3630 "The document contains unsaved work. "
3631 "Do you want to save it before closing?",
3632 "Save and Close", "Close without saving", "Cancel",
3633 0,
3634 2 );
3635 }
3636 else
3637 {
3638 query=QMessageBox::warning(this, "Texmaker",
3639 tr("The document contains unsaved work. "
3640 "Do you want to save it before closing?"),
3641 tr("Save and Close"), tr("Don't Save and Close"), tr("Cancel"),
3642 0,
3643 2 );
3644 }
3645 switch( query )
3646 {
3647 case 0:
3648 fileSave();
3649 filenames.remove(currentEditorView());
3650 comboFiles->removeItem(comboFiles->currentIndex());
3651 delete OpenedFilesListWidget->currentItem();
3652 delete currentEditorView();
3653 break;
3654 case 1:
3655 filenames.remove(currentEditorView());
3656 comboFiles->removeItem(comboFiles->currentIndex());
3657 delete OpenedFilesListWidget->currentItem();
3658 delete currentEditorView();
3659 break;
3660 case 2:
3661 default:
3662 return;
3663 break;
3664 }
3665 }
3666 else
3667 {
3668 filenames.remove(currentEditorView());
3669 comboFiles->removeItem(comboFiles->currentIndex());
3670 delete OpenedFilesListWidget->currentItem();
3671 delete currentEditorView();
3672 }
3673 UpdateCaption();
3674 }
3675
fileCloseRequested(int index)3676 void Texmaker::fileCloseRequested( int index)
3677 {
3678 EditorView->setCurrentIndex(index);
3679 fileClose();
3680 }
3681
fileCloseAll()3682 void Texmaker::fileCloseAll()
3683 {
3684 bool go=true;
3685 int query;
3686 QString locale = TexmakerApp::instance()->language.left(2);
3687 while (currentEditorView() && go)
3688 {
3689 if (currentEditorView()->editor->document()->isModified())
3690 {
3691 if (locale=="en")
3692 {
3693 query=QMessageBox::warning(this, "Texmaker",
3694 "The document contains unsaved work. "
3695 "Do you want to save it before closing?",
3696 "Save and Close", "Close without saving", "Cancel",
3697 0,
3698 2 );
3699 }
3700 else
3701 {
3702 query=QMessageBox::warning(this, "Texmaker",
3703 tr("The document contains unsaved work. "
3704 "Do you want to save it before closing?"),
3705 tr("Save and Close"), tr("Don't Save and Close"), tr("Cancel"),
3706 0,
3707 2 );
3708 }
3709 switch(query)
3710 {
3711 case 0:
3712 fileSave();
3713 filenames.remove(currentEditorView());
3714 comboFiles->removeItem(comboFiles->currentIndex());
3715 delete OpenedFilesListWidget->currentItem();
3716 delete currentEditorView();
3717 break;
3718 case 1:
3719 filenames.remove(currentEditorView());
3720 comboFiles->removeItem(comboFiles->currentIndex());
3721 delete OpenedFilesListWidget->currentItem();
3722 delete currentEditorView();
3723 break;
3724 case 2:
3725 default:
3726 go=false;
3727 return;
3728 break;
3729 }
3730 }
3731 else
3732 {
3733 filenames.remove(currentEditorView());
3734 comboFiles->removeItem(comboFiles->currentIndex());
3735 delete OpenedFilesListWidget->currentItem();
3736 delete currentEditorView();
3737 }
3738 }
3739 UpdateCaption();
3740 }
3741
fileExit()3742 void Texmaker::fileExit()
3743 {
3744 if (clean_exit) AutoCleanAll();
3745 SaveSettings();
3746 #ifdef INTERNAL_BROWSER
3747 if (browserWindow) browserWindow->close();
3748 if (diffWindow) diffWindow->close();
3749 #endif
3750
3751 if (pdfviewerWidget) {StackedViewers->removeWidget(pdfviewerWidget);delete(pdfviewerWidget);}
3752 if (pdfviewerWindow) pdfviewerWindow->close();
3753 bool accept=true;
3754 int query;
3755 QString locale = TexmakerApp::instance()->language.left(2);
3756 while (currentEditorView() && accept)
3757 {
3758 if (currentEditorView()->editor->document()->isModified())
3759 {
3760 if (locale=="en")
3761 {
3762 query=QMessageBox::warning(this, "Texmaker",
3763 "The document contains unsaved work. "
3764 "Do you want to save it before closing?",
3765 "Save and Close", "Close without saving", "Cancel",
3766 0,
3767 2 );
3768 }
3769 else
3770 {
3771 query=QMessageBox::warning(this, "Texmaker",
3772 tr("The document contains unsaved work. "
3773 "Do you want to save it before closing?"),
3774 tr("Save and Close"), tr("Don't Save and Close"), tr("Cancel"),
3775 0,
3776 2 );
3777 }
3778 switch(query)
3779 {
3780 case 0:
3781 fileSave();
3782 filenames.remove(currentEditorView());
3783 comboFiles->removeItem(comboFiles->currentIndex());
3784 delete OpenedFilesListWidget->currentItem();
3785 delete currentEditorView();
3786 break;
3787 case 1:
3788 filenames.remove(currentEditorView());
3789 comboFiles->removeItem(comboFiles->currentIndex());
3790 delete OpenedFilesListWidget->currentItem();
3791 delete currentEditorView();
3792 break;
3793 case 2:
3794 default:
3795 accept=false;
3796 break;
3797 }
3798
3799 }
3800 else
3801 {
3802 filenames.remove(currentEditorView());
3803 comboFiles->removeItem(comboFiles->currentIndex());
3804 delete OpenedFilesListWidget->currentItem();
3805 delete currentEditorView();
3806 }
3807 }
3808
3809 if (accept)
3810 {
3811 if (eraseSettings && QFile::exists(settingsFileName))
3812 {
3813 QFile file(settingsFileName);
3814 file.open( QIODevice::ReadOnly );
3815 file.remove();
3816 }
3817 if (replaceSettings)
3818 {
3819 QString from_file = QFileDialog::getOpenFileName(this,tr("Select a File"),QDir::homePath(),"Setting files (*.ini);;All files (*.*)");
3820 if (!from_file.isEmpty() && QFile::exists(from_file))
3821 {
3822 if (!settingsFileName.isEmpty() && QFile::exists(settingsFileName))
3823 {
3824 QFile file(settingsFileName);
3825 file.open( QIODevice::ReadOnly );
3826 file.remove();
3827 QFile fichier_or(from_file);
3828 fichier_or.copy(settingsFileName);
3829 }
3830 }
3831 else
3832 {
3833 replaceSettings=false;
3834 return;
3835 }
3836 }
3837 qApp->quit();
3838 }
3839 else
3840 {
3841 eraseSettings=false;
3842 replaceSettings=false;
3843 }
3844 }
3845
closeEvent(QCloseEvent * e)3846 void Texmaker::closeEvent(QCloseEvent *e)
3847 {
3848 if (clean_exit) AutoCleanAll();
3849 SaveSettings();
3850 #ifdef INTERNAL_BROWSER
3851 if (browserWindow) browserWindow->close();
3852 if (diffWindow) diffWindow->close();
3853 #endif
3854
3855 if (pdfviewerWidget) {StackedViewers->removeWidget(pdfviewerWidget);delete(pdfviewerWidget);}
3856 if (pdfviewerWindow) pdfviewerWindow->close();
3857 bool accept=true;
3858 int query;
3859 QString locale = TexmakerApp::instance()->language.left(2);
3860
3861 while (currentEditorView() && accept)
3862 {
3863 if (currentEditorView()->editor->document()->isModified())
3864 {
3865 if (locale=="en")
3866 {
3867 query=QMessageBox::warning(this, "Texmaker",
3868 "The document contains unsaved work. "
3869 "Do you want to save it before closing?",
3870 "Save and Close", "Close without saving", "Cancel",
3871 0,
3872 2 );
3873 }
3874 else
3875 {
3876 query=QMessageBox::warning(this, "Texmaker",
3877 tr("The document contains unsaved work. "
3878 "Do you want to save it before closing?"),
3879 tr("Save and Close"), tr("Don't Save and Close"), tr("Cancel"),
3880 0,
3881 2 );
3882 }
3883 switch(query)
3884 {
3885 case 0:
3886 fileSave();
3887 filenames.remove(currentEditorView());
3888 comboFiles->removeItem(comboFiles->currentIndex());
3889 delete OpenedFilesListWidget->currentItem();
3890 delete currentEditorView();
3891 break;
3892 case 1:
3893 filenames.remove(currentEditorView());
3894 comboFiles->removeItem(comboFiles->currentIndex());
3895 delete OpenedFilesListWidget->currentItem();
3896 delete currentEditorView();
3897 break;
3898 case 2:
3899 default:
3900 accept=false;
3901 break;
3902 }
3903 }
3904 else
3905 {
3906 filenames.remove(currentEditorView());
3907 comboFiles->removeItem(comboFiles->currentIndex());
3908 delete OpenedFilesListWidget->currentItem();
3909 delete currentEditorView();
3910 }
3911 }
3912 if (accept) e->accept();
3913 else e->ignore();
3914 }
3915
3916
fileOpenRecent()3917 void Texmaker::fileOpenRecent()
3918 {
3919 QAction *action = qobject_cast<QAction *>(sender());
3920 if (action)
3921 {
3922 load(action->data().toString());
3923 if (embedinternalpdf && builtinpdfview && showpdfview)
3924 {
3925 if ( !currentEditorView() || !singlemode ) return;
3926 QString finame=getName();
3927 QFileInfo fi(finame);
3928 QString basename=fi.completeBaseName();
3929 QString pdfname=outputName(finame,".pdf");
3930 QFileInfo pdfi(pdfname);
3931 if (pdfi.exists() && pdfi.isReadable())
3932 {
3933 if (pdfviewerWidget)
3934 {
3935 pdfviewerWidget->openFile(outputName(finame,".pdf"),viewpdf_command,ghostscript_command);
3936 StackedViewers->setCurrentWidget(pdfviewerWidget);
3937 //pdfviewerWidget->raise();
3938 pdfviewerWidget->show();
3939 }
3940 else
3941 {
3942 // pdfviewerWidget=new PdfViewer(outputName(finame,".pdf"),viewpdf_command, this);
3943 pdfviewerWidget=new PdfViewerWidget(outputName(finame,".pdf"),viewpdf_command,ghostscript_command,lp_options,QKeySequence(keyToggleFocus),pdfCheckerLang,lastScale,StackedViewers);
3944 pdfviewerWidget->centralToolBarBis->setMinimumHeight(centralToolBarBis->height());
3945 pdfviewerWidget->centralToolBarBis->setMaximumHeight(centralToolBarBis->height());
3946 connect(pdfviewerWidget, SIGNAL(openDocAtLine(const QString&, int, bool)), this, SLOT(fileOpenAndGoto(const QString&, int, bool)));
3947 connect(pdfviewerWidget, SIGNAL(sendFocusToEditor()), this, SLOT(getFocusToEditor()));
3948 connect(pdfviewerWidget, SIGNAL(sendPaperSize(const QString&)), this, SLOT(setPrintPaperSize(const QString&)));
3949 StackedViewers->addWidget(pdfviewerWidget);
3950 StackedViewers->setCurrentWidget(pdfviewerWidget);
3951 //pdfviewerWidget->raise();
3952 pdfviewerWidget->show();
3953 pdfviewerWidget->openFile(outputName(finame,".pdf"),viewpdf_command,ghostscript_command);
3954 }
3955 }
3956 }
3957 }
3958 if (currentEditorView()) currentEditorView()->editor->setFocus();
3959 }
3960
AddRecentFile(const QString & f)3961 void Texmaker::AddRecentFile(const QString &f)
3962 {
3963 QString nativeFileName = QDir::toNativeSeparators(f);
3964 if (recentFilesList.contains(nativeFileName))
3965 {
3966 recentFilesList.move(recentFilesList.indexOf(nativeFileName), 0);
3967 UpdateRecentFile();
3968 return;
3969 }
3970 if (recentFilesList.count() < 10) recentFilesList.prepend(nativeFileName);
3971 else
3972 {
3973 recentFilesList.removeLast();
3974 recentFilesList.prepend(nativeFileName);
3975 }
3976 UpdateRecentFile();
3977 }
3978
UpdateRecentFile()3979 void Texmaker::UpdateRecentFile()
3980 {
3981 for (int i=0; i < recentFilesList.count(); i++)
3982 {
3983 recentFileActs[i]->setIconText(recentFilesList.at(i));
3984
3985 recentFileActs[i]->setData(recentFilesList.at(i));
3986 recentFileActs[i]->setVisible(true);
3987 }
3988 for (int j = recentFilesList.count(); j < 10; ++j) recentFileActs[j]->setVisible(false);
3989 }
3990
CleanRecent()3991 void Texmaker::CleanRecent()
3992 {
3993 recentFilesList.clear();
3994 UpdateRecentFile();
3995 }
3996
filePrint()3997 void Texmaker::filePrint()
3998 {
3999 if ( !currentEditorView() ) return;
4000 QTextDocument *document = currentEditorView()->editor->document();
4001 QPrinter printer;
4002 QPrintDialog *dlg = new QPrintDialog(&printer, this);
4003 if (dlg->exec() != QDialog::Accepted) return;
4004 document->print(&printer);
4005 }
4006
fileOpenAndGoto(const QString & f,int line,bool focus)4007 void Texmaker::fileOpenAndGoto(const QString &f, int line,bool focus)
4008 {
4009 load(f);
4010 if (currentEditorView())
4011 {
4012 QTextCursor cur=currentEditorView()->editor->textCursor();
4013 cur.movePosition(QTextCursor::End);
4014 currentEditorView()->editor->setTextCursor(cur);
4015 currentEditorView()->editor->gotoLine(line-1);
4016 //currentEditorView()->editor->ensureCursorVisible();
4017 //currentEditorView()->editor->setHightLightLine();
4018 }
4019 setLine(QString::number(line));
4020 if (focus) getFocusToEditor();
4021 }
4022
getFocusToEditor()4023 void Texmaker::getFocusToEditor()
4024 {
4025 #if !defined(Q_OS_MAC)
4026 show();
4027 if (windowState()==Qt::WindowMinimized) setWindowState(windowState() & ~Qt::WindowMinimized | Qt::WindowActive);
4028 #endif
4029 show();
4030 if (windowState()==Qt::WindowMinimized) setWindowState(windowState() & ~Qt::WindowMinimized | Qt::WindowActive);
4031 qApp->setActiveWindow(this);
4032 activateWindow();
4033 setFocus();
4034 if (currentEditorView()) currentEditorView()->editor->setFocus();
4035 }
4036
fileReload()4037 void Texmaker::fileReload()
4038 {
4039 if ( !currentEditorView() ) return;
4040 if ( getName().startsWith("untitled") ) return;
4041 QString f=filenames[currentEditorView()];
4042 if (currentEditorView()->editor->document()->isModified())
4043 {
4044 switch( QMessageBox::warning(this, "Texmaker",
4045 tr("The document contains unsaved work."
4046 "You will lose changes by reloading the document."),
4047 tr("Reload the file"), tr("Cancel"),
4048 0,
4049 1 ) )
4050 {
4051 case 0:
4052 filenames.remove(currentEditorView());
4053 comboFiles->removeItem(comboFiles->currentIndex());
4054 delete OpenedFilesListWidget->currentItem();
4055 delete currentEditorView();
4056 load(f);
4057 break;
4058 case 1:
4059 default:
4060 return;
4061 break;
4062 }
4063 }
4064 else
4065 {
4066 filenames.remove(currentEditorView());
4067 comboFiles->removeItem(comboFiles->currentIndex());
4068 delete OpenedFilesListWidget->currentItem();
4069 delete currentEditorView();
4070 load(f);
4071 }
4072 }
4073
allReload()4074 void Texmaker::allReload()
4075 {
4076 LatexEditorView *temp = new LatexEditorView(EditorView,EditorFont,svnEnable,showline,edcolors(),hicolors(),inlinespellcheck,spell_ignored_words,spellChecker,tabspaces,tabwidth,QKeySequence(keyToggleFocus),getName(),userTagsList);
4077 temp=currentEditorView();
4078 FilesMap::Iterator it;
4079 FilesMap tempfilenames=filenames;
4080 for( it = tempfilenames.begin(); it != tempfilenames.end(); ++it )
4081 {
4082 EditorView->setCurrentIndex(EditorView->indexOf(it.key()));
4083 fileReload();
4084 }
4085 EditorView->setCurrentIndex(EditorView->indexOf(temp));
4086 UpdateCaption();
4087 }
4088
listSelectionActivated(int index)4089 void Texmaker::listSelectionActivated(int index)
4090 {
4091 disconnect(OpenedFilesListWidget, SIGNAL(itemClicked ( QListWidgetItem*)), this, SLOT(OpenedFileActivated(QListWidgetItem*)));
4092 if ((index>-1) && (index<OpenedFilesListWidget->count())) OpenedFilesListWidget->setCurrentRow(index);
4093 connect(OpenedFilesListWidget, SIGNAL(itemClicked ( QListWidgetItem*)), this, SLOT(OpenedFileActivated(QListWidgetItem*)));
4094 QString f=comboFiles->itemData(index, Qt::UserRole).toString();
4095 FilesMap::Iterator it;
4096 QString fw32,funix,forig;
4097 for( it = filenames.begin(); it != filenames.end(); ++it )
4098 {
4099 forig=filenames[it.key()];
4100 fw32=filenames[it.key()];
4101 funix=filenames[it.key()];
4102 fw32.replace(QString("\\"),QString("/"));
4103 funix.replace(QString("/"),QString("\\"));
4104 if ( (forig==f) || (fw32==f) || (funix==f))
4105 {
4106 EditorView->setCurrentIndex(EditorView->indexOf(it.key()));
4107 }
4108 }
4109 }
4110
ToggleMasterCurrent()4111 void Texmaker::ToggleMasterCurrent()
4112 {
4113 QString dest;
4114 FilesMap::Iterator it;
4115 QString fw32,funix,forig;
4116 if (singlemode)
4117 {
4118 lastChild="";
4119 return;
4120 }
4121 if (getName()==MasterName)
4122 {
4123 dest=lastChild;
4124 }
4125 else
4126 {
4127 lastChild=getName();
4128 dest=MasterName;
4129 }
4130 if (!dest.isEmpty())
4131 {
4132 for( it = filenames.begin(); it != filenames.end(); ++it )
4133 {
4134 forig=filenames[it.key()];
4135 fw32=filenames[it.key()];
4136 funix=filenames[it.key()];
4137 fw32.replace(QString("\\"),QString("/"));
4138 funix.replace(QString("/"),QString("\\"));
4139 if ( (forig==dest) || (fw32==dest) || (funix==dest))
4140 {
4141 EditorView->setCurrentIndex(EditorView->indexOf(it.key()));
4142 }
4143 }
4144 }
4145 }
4146
4147 //////////////////////////// EDIT ///////////////////////
editUndo()4148 void Texmaker::editUndo()
4149 {
4150 if ( !currentEditorView() ) return;
4151 currentEditorView()->editor->undoText();
4152 }
4153
editRedo()4154 void Texmaker::editRedo()
4155 {
4156 if ( !currentEditorView() ) return;
4157 currentEditorView()->editor->redoText();
4158 }
4159
editCut()4160 void Texmaker::editCut()
4161 {
4162 if ( !currentEditorView() ) return;
4163 currentEditorView()->editor->cut();
4164 }
4165
editCopy()4166 void Texmaker::editCopy()
4167 {
4168 if ( !currentEditorView() ) return;
4169 currentEditorView()->editor->copy();
4170 }
4171
editPaste()4172 void Texmaker::editPaste()
4173 {
4174 if ( !currentEditorView() ) return;
4175 currentEditorView()->editor->paste();
4176 }
4177
editSelectAll()4178 void Texmaker::editSelectAll()
4179 {
4180 if ( !currentEditorView() ) return;
4181 currentEditorView()->editor->selectAll();
4182 }
4183
editFindInDirectory()4184 void Texmaker::editFindInDirectory()
4185 {
4186 if (!scanDialog)
4187 {
4188 scanDialog = new ScanDialog(this);
4189 connect(scanDialog, SIGNAL(openFileAtLine(const QString&, int, bool)), this, SLOT(fileOpenAndGoto(const QString&, int, bool)));
4190 }
4191 scanDialog->show();
4192 scanDialog->raise();
4193 }
4194
editFind()4195 void Texmaker::editFind()
4196 {
4197 if ( !currentEditorView() ) return;
4198 currentEditorView()->showFind();
4199 }
4200
editFindNext()4201 void Texmaker::editFindNext()
4202 {
4203 if ( !currentEditorView() ) return;
4204 currentEditorView()->showFindNext();
4205 }
4206
4207
editReplace()4208 void Texmaker::editReplace()
4209 {
4210 if ( !currentEditorView() ) return;
4211 currentEditorView()->showReplace();
4212 }
4213
editGotoLine()4214 void Texmaker::editGotoLine()
4215 {
4216 if ( !currentEditorView() ) return;
4217 currentEditorView()->showGoto();
4218 }
4219
editComment()4220 void Texmaker::editComment()
4221 {
4222 if ( !currentEditorView() ) return;
4223 currentEditorView()->editor->commentSelection();
4224 }
4225
editUncomment()4226 void Texmaker::editUncomment()
4227 {
4228 if ( !currentEditorView() ) return;
4229 currentEditorView()->editor->uncommentSelection();
4230 }
4231
editIndent()4232 void Texmaker::editIndent()
4233 {
4234 if ( !currentEditorView() ) return;
4235 currentEditorView()->editor->indentSelection();
4236 }
4237
editUnindent()4238 void Texmaker::editUnindent()
4239 {
4240 if ( !currentEditorView() ) return;
4241 currentEditorView()->editor->unindentSelection();
4242 }
4243
editSpell()4244 void Texmaker::editSpell()
4245 {
4246 if ( !currentEditorView() ) return;
4247 if (spelldicExist())
4248 {
4249 SpellerDialog *spellDlg=new SpellerDialog(this,currentEditorView()->editor,spell_ignored_words);
4250 if (spellDlg->exec())
4251 {
4252 spell_ignored_words=spellDlg->alwaysignoredwordList.join(",");
4253 currentEditorView()->editor->highlighter->SetAlwaysIgnoredWords(spell_ignored_words);
4254 currentEditorView()->editor->highlighter->rehighlight();
4255 }
4256 }
4257 else
4258 {
4259 QMessageBox::warning( this,tr("Error"),tr("Error : Can't open the dictionary"));
4260 return;
4261 }
4262 }
4263
editTipTab()4264 void Texmaker::editTipTab()
4265 {
4266 if ( !currentEditorView() ) return;
4267 OutputTextEdit->clear();
4268 OutputTextEdit->insertLine("Use the Tab key to reach the next "+QString(0x2022)+" field");
4269 }
4270
editRunScript()4271 void Texmaker::editRunScript()
4272 {
4273 if ( !currentEditorView() ) return;
4274 QString currentDir=QDir::homePath();
4275 if (!lastScript.isEmpty())
4276 {
4277 QFileInfo fi(lastScript);
4278 if (fi.exists() && fi.isReadable()) currentDir=fi.absolutePath();
4279 }
4280 QString fn = QFileDialog::getOpenFileName(this,tr("Browse script"),currentDir,"Script (*.tms)");
4281 if (fn.isEmpty()) return;
4282 lastScript=fn;
4283 currentEditorView()->editor->ExecuteScript(fn);
4284 }
4285
editRunFurnishedScript()4286 void Texmaker::editRunFurnishedScript()
4287 {
4288 QString actData;
4289 QAction *action = qobject_cast<QAction *>(sender());
4290 if ( !currentEditorView() ) return;
4291 if (action)
4292 {
4293 actData=action->data().toString();
4294 #if defined(Q_OS_UNIX) && !defined(Q_OS_MAC)
4295
4296 #ifdef USB_VERSION
4297 QString scriptfile=QCoreApplication::applicationDirPath() + "/"+actData;
4298 #else
4299 QString scriptfile=PREFIX"/share/texmaker/"+actData;
4300 #endif
4301
4302 #endif
4303 #if defined(Q_OS_MAC)
4304 QString scriptfile=QCoreApplication::applicationDirPath() + "/../Resources/"+actData;
4305 #endif
4306 #if defined(Q_OS_WIN32)
4307 QString scriptfile=QCoreApplication::applicationDirPath() + "/"+actData;
4308 #endif
4309
4310 QFileInfo fic(scriptfile);
4311 if (fic.exists() && fic.isReadable() )
4312 {
4313 currentEditorView()->editor->ExecuteScript(scriptfile);
4314 }
4315 else { QMessageBox::warning( this,tr("Error"),tr("File not found"));}
4316
4317
4318 }
4319
4320 }
4321
4322 /************ by Robin.Watts ***********************/
lineTo(LatexEditor * editor,int line)4323 static void lineTo(LatexEditor *editor, int line)
4324 {
4325 QTextCursor cur=editor->textCursor();
4326 cur.movePosition(QTextCursor::End);
4327 editor->setTextCursor(cur);
4328 editor->gotoLine(line);
4329 editor->setFocus();
4330 }
4331
foldAll()4332 void Texmaker::foldAll()
4333 {
4334 if ( !currentEditorView() ) return;
4335
4336 QAction *action = qobject_cast<QAction *>(sender());
4337
4338 if (!action) return;
4339
4340 doFoldAll(action->data().toInt());
4341 }
4342
foldAllUnder()4343 void Texmaker::foldAllUnder()
4344 {
4345 if ( !currentEditorView() ) return;
4346
4347 QAction *action = qobject_cast<QAction *>(sender());
4348
4349 if (!action) return;
4350
4351 int i = action->data().toInt();
4352 int n = 5;
4353
4354 for (n--; n >= i; n--)
4355 doFoldAll(n);
4356 }
4357
doFoldAll(int i)4358 void Texmaker::doFoldAll(int i)
4359 {
4360 LatexEditor *editor = currentEditorView()->editor;
4361 QTextDocument *doc = editor->document();
4362 int line = editor->textCursor().blockNumber();
4363 int newLine = line;
4364
4365 QMapIterator<int, int> it(editor->foldableLines);
4366 while (it.hasNext()) {
4367 it.next();
4368
4369 int startLine = it.key();
4370 int endLine = it.value();
4371 QTextBlock block = doc->findBlockByNumber(startLine);
4372 QString text = block.text();
4373 if (text.contains(foldClasses[i], Qt::CaseInsensitive))
4374 {
4375 editor->fold(startLine, endLine);
4376 if (newLine >= startLine && newLine <= endLine)
4377 newLine = startLine;
4378 }
4379 }
4380
4381 lineTo(editor, newLine);
4382 }
4383
unfoldAll()4384 void Texmaker::unfoldAll()
4385 {
4386 if ( !currentEditorView() ) return;
4387
4388 QAction *action = qobject_cast<QAction *>(sender());
4389
4390 if (!action) return;
4391
4392 int i=action->data().toInt();
4393 doUnfoldAll(i);
4394 }
4395
unfoldAllUnder()4396 void Texmaker::unfoldAllUnder()
4397 {
4398 if ( !currentEditorView() ) return;
4399
4400 QAction *action = qobject_cast<QAction *>(sender());
4401
4402 if (!action) return;
4403
4404 int i = action->data().toInt();
4405 int n = 5;
4406
4407 for (n--; n >= i; n--)
4408 doUnfoldAll(n);
4409 }
4410
doUnfoldAll(int i)4411 void Texmaker::doUnfoldAll(int i)
4412 {
4413 LatexEditor *editor = currentEditorView()->editor;
4414 QTextDocument *doc = editor->document();
4415
4416 QMapIterator<int, int> it(editor->foldedLines);
4417 while (it.hasNext()) {
4418 it.next();
4419
4420 int startLine = it.key();
4421 QTextBlock block = doc->findBlockByNumber(startLine);
4422 QString text = block.text();
4423 if (text.contains(foldClasses[i], Qt::CaseInsensitive))
4424 editor->unfold(startLine, it.value());
4425 }
4426 }
4427
foldEnclosing()4428 void Texmaker::foldEnclosing()
4429 {
4430 if ( !currentEditorView() ) return;
4431 LatexEditor *editor = currentEditorView()->editor;
4432 int line = editor->textCursor().blockNumber();
4433
4434 /* Find the largest folded area at this point */
4435 int foldedStartLine = INT_MAX;
4436 int foldedEndLine = INT_MIN;
4437 QMapIterator<int, int> it(editor->foldedLines);
4438 while (it.hasNext()) {
4439 it.next();
4440 int startLine = it.key();
4441 int endLine = it.value();
4442 if (startLine <= line && endLine >= line && foldedStartLine >= startLine && foldedEndLine <= endLine)
4443 {
4444 foldedStartLine = startLine;
4445 foldedEndLine = endLine;
4446 }
4447 }
4448
4449 /* Now find the smallest foldable area, larger than the folded area. */
4450 int bestStartLine = INT_MIN;
4451 int bestEndLine = INT_MAX;
4452 QMapIterator<int, int> it2(editor->foldableLines);
4453 while (it2.hasNext()) {
4454 it2.next();
4455 int startLine = it2.key();
4456 int endLine = it2.value();
4457 if (startLine <= line && endLine > line &&
4458 bestStartLine <= startLine && bestEndLine >= endLine &&
4459 foldedStartLine > startLine && foldedEndLine <= endLine)
4460 {
4461 bestStartLine = startLine;
4462 bestEndLine = endLine;
4463 }
4464 }
4465 if (bestStartLine >= 0)
4466 {
4467 editor->fold(bestStartLine, bestEndLine);
4468 lineTo(editor, bestStartLine);
4469 }
4470 else
4471 {
4472 /* FIXME: Beep! */
4473 }
4474 }
4475
unfoldEnclosing()4476 void Texmaker::unfoldEnclosing()
4477 {
4478 if ( !currentEditorView() ) return;
4479 LatexEditor *editor = currentEditorView()->editor;
4480 int line = editor->textCursor().blockNumber();
4481 int bestStartLine = INT_MAX;
4482 int bestEndLine = INT_MIN;
4483 QMapIterator<int, int> it(editor->foldedLines);
4484 while (it.hasNext()) {
4485 it.next();
4486 int startLine = it.key();
4487 int endLine = it.value();
4488 if (startLine <= line && endLine > line && bestStartLine >= startLine && bestEndLine <= endLine)
4489 {
4490 bestStartLine = startLine;
4491 bestEndLine = endLine;
4492 }
4493 }
4494 if (bestEndLine >= 0)
4495 {
4496 editor->unfold(bestStartLine, bestEndLine);
4497 lineTo(editor, bestStartLine + (bestStartLine != bestEndLine ? 1 : 0));
4498 }
4499 else
4500 {
4501 /* FIXME: Beep! */
4502 }
4503 }
4504 /////////////// CONFIG ////////////////////
ReadSettings()4505 void Texmaker::ReadSettings()
4506 {
4507
4508 #ifdef USB_VERSION
4509 QSettings *config=new QSettings(QCoreApplication::applicationDirPath()+"/texmaker.ini",QSettings::IniFormat); //for USB-stick version :
4510 #else
4511 QSettings *config=new QSettings(QSettings::IniFormat,QSettings::UserScope,"xm1","texmaker");
4512 #endif
4513 settingsFileName=config->fileName();
4514 if (!config->contains("IniMode"))
4515 {
4516 delete config;
4517 config=new QSettings("xm1","texmaker");
4518 }
4519 config->beginGroup( "texmaker" );
4520 singlemode=true;
4521
4522
4523 QFontDatabase fdb;
4524 QStringList xf = fdb.families();
4525 QString deft;
4526
4527 bool new_user=(!config->contains("GUI/New Version"));
4528
4529 modern_style=config->value( "GUI/Style",true).toBool();
4530 new_gui=config->value( "GUI/New Version",false).toBool();
4531
4532
4533 QRect screen = QApplication::desktop()->screenGeometry();
4534 int w= config->value( "Geometries/MainwindowWidth",screen.width()-150).toInt();
4535 int h= config->value( "Geometries/MainwindowHeight",screen.height()-100).toInt() ;
4536 int x= config->value( "Geometries/MainwindowX",30).toInt();
4537 int y= config->value( "Geometries/MainwindowY",30).toInt() ;
4538 resize(w,h);
4539 move(x,y);
4540 windowstate=config->value("MainWindowState").toByteArray();
4541 winmaximized=config->value("MainWindowMaximized",false).toBool();
4542
4543 splitter1state=config->value("Splitter1State").toByteArray();
4544 splitter2state=config->value("Splitter2State").toByteArray();
4545 splitter3state=config->value("Splitter3State").toByteArray();
4546 psize=config->value( "Print/PaperSize","a4").toString();
4547 lastScale=config->value( "PdfView/Scale",10).toFloat()/100.0;
4548 #if defined(Q_OS_WIN32)
4549 if (xf.contains("Courier New",Qt::CaseInsensitive)) deft="Courier New";
4550 else deft=qApp->font().family();
4551 QString fam=config->value("Editor/Font Family",deft).toString();
4552 int si=config->value( "Editor/Font Size",10).toInt();
4553 #else
4554 if (xf.contains("DejaVu Sans Mono",Qt::CaseInsensitive)) deft="DejaVu Sans Mono";
4555 else if (xf.contains("Lucida Sans Typewriter",Qt::CaseInsensitive)) deft="Lucida Sans Typewriter";
4556 else deft=qApp->font().family();
4557 QString fam=config->value("Editor/Font Family",deft).toString();
4558 int si=config->value( "Editor/Font Size",qApp->font().pointSize()).toInt();
4559 #endif
4560 QFont F(fam,si);
4561 EditorFont=F;
4562
4563 tabspaces=config->value( "Editor/TabSpaces",false).toBool();
4564 tabwidth=config->value( "Editor/TabWidth",4).toInt();
4565 wordwrap=config->value( "Editor/WordWrap",true).toBool();
4566 watchfiles=config->value( "Editor/Watcher",false).toBool();
4567 autosave=config->value( "Editor/AutoSave",false).toBool();
4568 parenmatch=config->value( "Editor/Parentheses Matching",true).toBool();
4569 showline=config->value( "Editor/Line Numbers",true).toBool();
4570 completion=config->value( "Editor/Completion",true).toBool();
4571 userCompletionList=config->value( "Editor/UserCompletion",true).toStringList();
4572 svnEnable=config->value( "Editor/SvnEnable",false).toBool();
4573 svnPath=config->value("Editor/SvnPath","").toString();
4574 shortcuts.clear();
4575 QStringList data,shortcut;
4576 data=config->value("Shortcuts/data").toStringList();
4577 shortcut=config->value("Shortcuts/shortcut").toStringList();
4578 QStringListIterator dataiterator(data);
4579 QStringListIterator shortcutiterator(shortcut);
4580 while ( dataiterator.hasNext() && shortcutiterator.hasNext())
4581 {
4582 QString d=dataiterator.next();
4583 if (!d.isEmpty()) shortcuts.insert(d,shortcutiterator.next());
4584 }
4585
4586 showoutputview=config->value("Show/OutputView",false).toBool();
4587 showstructview=config->value( "Show/Structureview",true).toBool();
4588 showpdfview=config->value( "Show/Pdfview",true).toBool();
4589 showsourceview=config->value( "Show/Sourceview",false).toBool();
4590 showfilesview=config->value( "Show/Filesview",false).toBool();
4591
4592 showPstricks=config->value( "Show/Pstricks",true).toBool();
4593 showMp=config->value( "Show/Metapost",true).toBool();
4594 showTikz=config->value( "Show/Tikz",true).toBool();
4595 showAsy=config->value( "Show/Asymptote",true).toBool();
4596 showEmphasis=config->value( "Show/Emphasis",true).toBool();
4597 showNewline=config->value( "Show/Newline",true).toBool();
4598 showMathmode=config->value( "Show/Mathmode",true).toBool();
4599 showIndice=config->value( "Show/Indice",true).toBool();
4600 showPuissance=config->value( "Show/Puissance",true).toBool();
4601 showSmallfrac=config->value( "Show/Smallfrac",true).toBool();
4602 showDfrac=config->value( "Show/Dfrac",true).toBool();
4603 showRacine=config->value( "Show/Racine",true).toBool();
4604
4605 extra_path=config->value("Tools/ExtraPath","").toString();
4606 useoutputdir=config->value( "Tools/OutputDir",false).toBool();
4607 clean_exit=config->value( "Tools/CleanWhenExit",false).toBool();
4608 quickmode=config->value( "Tools/Quick Mode",3).toInt();
4609 QString baseName = qApp->style()->objectName();
4610 builtinpdfview=config->value("Tools/IntegratedPdfViewer",true).toBool();
4611 embedinternalpdf=config->value("Tools/PdfInternalViewEmbed", screen.width() > 1400).toBool();
4612 singleviewerinstance=config->value("Tools/SingleViewerInstance",false).toBool();
4613 htlatex_options=config->value("Tools/HtOptions","\"\" \"\" \"\" -interaction=nonstopmode").toString();
4614
4615 #if defined(Q_OS_MAC)
4616
4617 keyToggleFocus=config->value("Shortcuts/togglefocus","Ctrl+$").toString();
4618 latex_command=config->value("Tools/Latex","\"latex\" -interaction=nonstopmode %.tex").toString();
4619 dvips_command=config->value("Tools/Dvips","\"dvips\" -o %.ps %.dvi").toString();
4620 ps2pdf_command=config->value("Tools/Ps2pdf","\"ps2pdf\" %.ps").toString();
4621 makeindex_command=config->value("Tools/Makeindex","\"makeindex\" %.idx").toString();
4622 bibtex_command=config->value("Tools/Bibtex","\"bibtex\" %.aux").toString();
4623 pdflatex_command=config->value("Tools/Pdflatex","\"pdflatex\" -synctex=1 -interaction=nonstopmode %.tex").toString();
4624 xelatex_command=config->value("Tools/Xelatex","\"xelatex\" -synctex=1 -interaction=nonstopmode %.tex").toString();
4625 lualatex_command=config->value("Tools/Lualatex","\"lualatex\" -interaction=nonstopmode %.tex").toString();
4626 if (lualatex_command.isEmpty()) lualatex_command=QString("\"lualatex\" -interaction=nonstopmode %.tex");
4627 if (xelatex_command.isEmpty()) xelatex_command=QString("\"xelatex\" -synctex=1 -interaction=nonstopmode %.tex");
4628 dvipdf_command=config->value("Tools/Dvipdf","\"dvipdfm\" %.dvi").toString();
4629 metapost_command=config->value("Tools/Metapost","\"mpost\" --interaction nonstopmode ").toString();
4630 viewdvi_command=config->value("Tools/Dvi","open %.dvi").toString();
4631 viewps_command=config->value("Tools/Ps","open %.ps").toString();
4632 viewpdf_command=config->value("Tools/Pdf","open %.pdf").toString();
4633 ghostscript_command=config->value("Tools/Ghostscript","gs").toString();
4634 asymptote_command=config->value("Tools/Asymptote","asy %.asy").toString();
4635 latexmk_command=config->value("Tools/Latexmk","\"latexmk\" -e \"$pdflatex=q/pdflatex -synctex=1 -interaction=nonstopmode/\" -pdf %.tex").toString();
4636 sweave_command=config->value("Tools/Sweave","R CMD Sweave %.Rnw").toString();
4637 texdoc_command=config->value("Tools/Texdoc","texdoc").toString();
4638 htlatex_command=config->value("Tools/Htlatex","htlatex").toString();
4639 quick_asy_command=config->value("Tools/QuickAsy","asy -f pdf -noView %.asy|open %.pdf").toString();
4640 lp_options=config->value("Tools/LP","-o fitplot").toString();
4641
4642 qApp->setStyle(QLatin1String("Fusion"));
4643 #endif
4644 #if defined(Q_OS_WIN32)
4645 keyToggleFocus=config->value("Shortcuts/togglefocus","Ctrl+Space").toString();
4646 latex_command=config->value("Tools/Latex","latex -interaction=nonstopmode %.tex").toString();
4647 dvips_command=config->value("Tools/Dvips","dvips -Pdownload35 -o %.ps %.dvi").toString();
4648 ps2pdf_command=config->value("Tools/Ps2pdf","ps2pdf %.ps").toString();
4649 makeindex_command=config->value("Tools/Makeindex","makeindex %.idx").toString();
4650 bibtex_command=config->value("Tools/Bibtex","bibtex %").toString();
4651 //bibtex %.aux
4652 pdflatex_command=config->value("Tools/Pdflatex","pdflatex -synctex=1 -interaction=nonstopmode %.tex").toString();
4653 xelatex_command=config->value("Tools/Xelatex","xelatex -synctex=1 -interaction=nonstopmode %.tex").toString();
4654 lualatex_command=config->value("Tools/Lualatex","lualatex -interaction=nonstopmode %.tex").toString();
4655 dvipdf_command=config->value("Tools/Dvipdf","dvipdfm %.dvi").toString();
4656 metapost_command=config->value("Tools/Metapost","mpost --interaction nonstopmode ").toString();
4657 viewdvi_command=config->value("Tools/Dvi","\"C:/Program Files/MiKTeX 2.9/miktex/bin/yap.exe\" %.dvi").toString();
4658 viewps_command=config->value("Tools/Ps","\"C:/Program Files/Ghostgum/gsview/gsview32.exe\" %.ps").toString();
4659 viewpdf_command=config->value("Tools/Pdf","\"C:/Program Files/Adobe/Reader 11.0/Reader/AcroRd32.exe\" %.pdf").toString();
4660 ghostscript_command=config->value("Tools/Ghostscript","\"C:/Program Files/gs/gs9.07/bin/gswin32c.exe\"").toString();
4661 asymptote_command=config->value("Tools/Asymptote","\"C:/Program Files/Asymptote/asy.exe\" %.asy").toString();
4662 latexmk_command=config->value("Tools/Latexmk","latexmk -e \"$pdflatex=q/pdflatex -synctex=1 -interaction=nonstopmode/\" -pdf %.tex").toString();
4663 sweave_command=config->value("Tools/Sweave","C:/Program Files/R/R-2.13.2/bin/R.exe CMD Sweave %.Rnw").toString();
4664 texdoc_command=config->value("Tools/Texdoc","texdoc").toString();
4665 htlatex_command=config->value("Tools/Htlatex","htlatex").toString();
4666 QString yap="C:/Program Files/MiKTeX 2.9/miktex/bin/yap.exe";
4667 QString gsview="C:/Program Files/Ghostgum/gsview/gsview32.exe";
4668 QString gswin="C:/Program Files/gs/gs9.21/bin/gswin32c.exe";
4669 QString acro="C:/Program Files/Adobe/Reader 11.0/Reader/AcroRd32.exe";
4670
4671 if (new_user)
4672 {
4673 if (!QFileInfo(gswin).exists())
4674 {
4675 if (QFileInfo("C:/Program Files (x86)/gs/gs9.21/bin/gswin32c.exe").exists()) gswin="C:/Program Files (x86)/gs/gs9.21/bin/gswin32c.exe";
4676 else if (QFileInfo("C:/Program Files/gs/gs9.20/bin/gswin32c.exe").exists()) gswin="C:/Program Files/gs/gs9.20/bin/gswin32c.exe";
4677 else if (QFileInfo("C:/Program Files (x86)/gs/gs9.20/bin/gswin32c.exe").exists()) gswin="C:/Program Files (x86)/gs/gs9.20/bin/gswin32c.exe";
4678 else if (QFileInfo("C:/Program Files/gs/gs9.19/bin/gswin32c.exe").exists()) gswin="C:/Program Files/gs/gs9.19/bin/gswin32c.exe";
4679 else if (QFileInfo("C:/Program Files (x86)/gs/gs9.19/bin/gswin32c.exe").exists()) gswin="C:/Program Files (x86)/gs/gs9.19/bin/gswin32c.exe";
4680 else if (QFileInfo("C:/Program Files/gs/gs9.18/bin/gswin32c.exe").exists()) gswin="C:/Program Files/gs/gs9.18/bin/gswin32c.exe";
4681 else if (QFileInfo("C:/Program Files (x86)/gs/gs9.18/bin/gswin32c.exe").exists()) gswin="C:/Program Files (x86)/gs/gs9.18/bin/gswin32c.exe";
4682 }
4683 ghostscript_command="\""+gswin+"\"";
4684 if (!QFileInfo(yap).exists())
4685 {
4686 if (QFileInfo("C:/Program Files (x86)/MiKTeX 2.9/miktex/bin/yap.exe").exists()) yap="C:/Program Files (x86)/MiKTeX 2.9/miktex/bin/yap.exe";
4687 else if (QFileInfo("C:/Program Files/MiKTeX 3.0/miktex/bin/yap.exe").exists()) yap="C:/Program Files/MiKTeX 3.0/miktex/bin/yap.exe";
4688 else if (QFileInfo("C:/Program Files (x86)/MiKTeX 3.0/miktex/bin/yap.exe").exists()) yap="C:/Program Files (x86)/MiKTeX 3.0/miktex/bin/yap.exe";
4689 else if (QFileInfo("C:/Program Files/MiKTeX 2.8/miktex/bin/yap.exe").exists()) yap="C:/Program Files/MiKTeX 2.8/miktex/bin/yap.exe";
4690 else if (QFileInfo("C:/Program Files (x86)/MiKTeX 2.8/miktex/bin/yap.exe").exists()) yap="C:/Program Files (x86)/MiKTeX 2.8/miktex/bin/yap.exe";
4691 else if (QFileInfo("C:/Program Files/MiKTeX 2.7/miktex/bin/yap.exe").exists()) yap="C:/Program Files/MiKTeX 2.7/miktex/bin/yap.exe";
4692 else if (QFileInfo("C:/Program Files (x86)/MiKTeX 2.7/miktex/bin/yap.exe").exists()) yap="C:/Program Files (x86)/MiKTeX 2.7/miktex/bin/yap.exe";
4693 else if (QFileInfo("C:/Program Files/MiKTeX 2.5/miktex/bin/yap.exe").exists()) yap="C:/Program Files/MiKTeX 2.5/miktex/bin/yap.exe";
4694 else if (QFileInfo("C:/Program Files (x86)/MiKTeX 2.5/miktex/bin/yap.exe").exists()) yap="C:/Program Files (x86)/MiKTeX 2.5/miktex/bin/yap.exe";
4695 else if (QFileInfo("C:/texlive/2009/bin/win32/dviout.exe").exists()) yap="C:/texlive/2009/bin/win32/dviout.exe";
4696 else if (QFileInfo("C:/texlive/2010/bin/win32/dviout.exe").exists()) yap="C:/texlive/2010/bin/win32/dviout.exe";
4697 else if (QFileInfo("C:/texlive/2011/bin/win32/dviout.exe").exists()) yap="C:/texlive/2011/bin/win32/dviout.exe";
4698 else if (QFileInfo("C:/texlive/2012/bin/win32/dviout.exe").exists()) yap="C:/texlive/2012/bin/win32/dviout.exe";
4699 else if (QFileInfo("C:/texlive/2013/bin/win32/dviout.exe").exists()) yap="C:/texlive/2013/bin/win32/dviout.exe";
4700 else if (QFileInfo("C:/texlive/2014/bin/win32/dviout.exe").exists()) yap="C:/texlive/2014/bin/win32/dviout.exe";
4701 else if (QFileInfo("C:/texlive/2015/bin/win32/dviout.exe").exists()) yap="C:/texlive/2015/bin/win32/dviout.exe";
4702 else if (QFileInfo("C:/texlive/2016/bin/win32/dviout.exe").exists()) yap="C:/texlive/2016/bin/win32/dviout.exe";
4703 else if (QFileInfo("C:/texlive/2017/bin/win32/dviout.exe").exists()) yap="C:/texlive/2017/bin/win32/dviout.exe";
4704 }
4705 viewdvi_command="\""+yap+"\" %.dvi";
4706 if (!QFileInfo(gsview).exists())
4707 {
4708 if (QFileInfo("C:/Program Files (x86)/Ghostgum/gsview/gsview32.exe").exists()) gsview="C:/Program Files (x86)/Ghostgum/gsview/gsview32.exe";
4709 else if (QFileInfo("C:/texlive/2009/bin/win32/psv.exe").exists()) gsview="C:/texlive/2009/bin/win32/psv.exe";
4710 else if (QFileInfo("C:/texlive/2010/bin/win32/psv.exe").exists()) gsview="C:/texlive/2010/bin/win32/psv.exe";
4711 else if (QFileInfo("C:/texlive/2011/bin/win32/psv.exe").exists()) gsview="C:/texlive/2011/bin/win32/psv.exe";
4712 else if (QFileInfo("C:/texlive/2012/bin/win32/psv.exe").exists()) gsview="C:/texlive/2012/bin/win32/psv.exe";
4713 else if (QFileInfo("C:/texlive/2013/bin/win32/psv.exe").exists()) gsview="C:/texlive/2012/bin/win32/psv.exe";
4714 else if (QFileInfo("C:/texlive/2014/bin/win32/psv.exe").exists()) gsview="C:/texlive/2014/bin/win32/psv.exe";
4715 else if (QFileInfo("C:/texlive/2015/bin/win32/psv.exe").exists()) gsview="C:/texlive/2015/bin/win32/psv.exe";
4716 else if (QFileInfo("C:/texlive/2016/bin/win32/psv.exe").exists()) gsview="C:/texlive/2016/bin/win32/psv.exe";
4717 else if (QFileInfo("C:/texlive/2017/bin/win32/psv.exe").exists()) gsview="C:/texlive/2017/bin/win32/psv.exe";
4718 }
4719 viewps_command="\""+gsview+"\" %.ps";
4720 if (!QFileInfo(acro).exists())
4721 {
4722 if (QFileInfo("C:/Program Files (x86)/Adobe/Reader 11.0/Reader/AcroRd32.exe").exists()) acro="C:/Program Files (x86)/Adobe/Reader 11.0/Reader/AcroRd32.exe";
4723 else if (QFileInfo("C:/Program Files/Adobe/Reader 10.0/Reader/AcroRd32.exe").exists()) acro="C:/Program Files/Adobe/Reader 10.0/Reader/AcroRd32.exe";
4724 else if (QFileInfo("C:/Program Files (x86)/Adobe/Reader 10.0/Reader/AcroRd32.exe").exists()) acro="C:/Program Files (x86)/Adobe/Reader 10.0/Reader/AcroRd32.exe";
4725 else if (QFileInfo("C:/Program Files/Adobe/Reader 9.0/Reader/AcroRd32.exe").exists()) acro="C:/Program Files/Adobe/Reader 9.0/Reader/AcroRd32.exe";
4726 else if (QFileInfo("C:/Program Files (x86)/Adobe/Reader 9.0/Reader/AcroRd32.exe").exists()) acro="C:/Program Files (x86)/Adobe/Reader 9.0/Reader/AcroRd32.exe";
4727 else if (QFileInfo("C:/Program Files/Adobe/Reader 8.0/Reader/AcroRd32.exe").exists()) acro="C:/Program Files/Adobe/Reader 8.0/Reader/AcroRd32.exe";
4728 else if (QFileInfo("C:/Program Files (x86)/Adobe/Reader 8.0/Reader/AcroRd32.exe").exists()) acro="C:/Program Files (x86)/Adobe/Reader 8.0/Reader/AcroRd32.exe";
4729 }
4730 viewpdf_command="\""+acro+"\" %.pdf";
4731 }
4732 //\"C:/Program Files/MiKTeX 2.7/miktex/bin/yap.exe\" -1 -s @%.tex %.dvi
4733 quick_asy_command=config->value("Tools/QuickAsy","\"C:/Program Files/Asymptote/asy.exe\" -f pdf -noView %.asy|"+viewpdf_command).toString();
4734 lp_options=config->value("Tools/LP","").toString();
4735
4736 qApp->setStyle(QLatin1String("Fusion"));
4737
4738 #endif
4739 #if defined(Q_OS_UNIX) && !defined(Q_OS_MAC)
4740 keyToggleFocus=config->value("Shortcuts/togglefocus","Ctrl+Space").toString();
4741 int desktop_env=1; // 1 : no kde ; 2: kde ; 3 : kde4 ;
4742 QStringList styles = QStyleFactory::keys();
4743 QString kdesession= ::getenv("KDE_FULL_SESSION");
4744 QString kdeversion= ::getenv("KDE_SESSION_VERSION");
4745 if (!kdesession.isEmpty()) desktop_env=2;
4746 if (!kdeversion.isEmpty()) desktop_env=3;
4747
4748 //desktop_env=1;
4749 latex_command=config->value("Tools/Latex","latex -interaction=nonstopmode %.tex").toString();
4750 dvips_command=config->value("Tools/Dvips","dvips -o %.ps %.dvi").toString();
4751 ps2pdf_command=config->value("Tools/Ps2pdf","ps2pdf %.ps").toString();
4752 makeindex_command=config->value("Tools/Makeindex","makeindex %.idx").toString();
4753 bibtex_command=config->value("Tools/Bibtex","bibtex %.aux").toString();
4754 pdflatex_command=config->value("Tools/Pdflatex","pdflatex -synctex=1 -interaction=nonstopmode %.tex").toString();
4755 xelatex_command=config->value("Tools/Xelatex","xelatex -synctex=1 -interaction=nonstopmode %.tex").toString();
4756 lualatex_command=config->value("Tools/Lualatex","lualatex -interaction=nonstopmode %.tex").toString();
4757 dvipdf_command=config->value("Tools/Dvipdf","dvipdfm %.dvi").toString();
4758 metapost_command=config->value("Tools/Metapost","mpost --interaction nonstopmode ").toString();
4759 // xdvi %.dvi -sourceposition @:%.tex
4760 // kdvi "file:%.dvi#src:@ %.tex"
4761 switch (desktop_env)
4762 {
4763 case 1:
4764 {
4765 viewdvi_command=config->value("Tools/Dvi","evince %.dvi").toString();
4766 viewps_command=config->value("Tools/Ps","evince %.ps").toString();
4767 viewpdf_command=config->value("Tools/Pdf","evince %.pdf").toString();
4768 }break;
4769 case 2:
4770 {
4771 viewdvi_command=config->value("Tools/Dvi","kdvi %.dvi").toString();
4772 viewps_command=config->value("Tools/Ps","kghostview %.ps").toString();
4773 viewpdf_command=config->value("Tools/Pdf","kpdf %.pdf").toString();
4774 }break;
4775 case 3:
4776 {
4777 viewdvi_command=config->value("Tools/Dvi","okular %.dvi").toString();
4778 viewps_command=config->value("Tools/Ps","okular %.ps").toString();
4779 viewpdf_command=config->value("Tools/Pdf","okular %.pdf").toString();
4780 }break;
4781 }
4782
4783
4784
4785 ghostscript_command=config->value("Tools/Ghostscript","gs").toString();
4786 asymptote_command=config->value("Tools/Asymptote","asy %.asy").toString();
4787 latexmk_command=config->value("Tools/Latexmk","latexmk -e \"$pdflatex=q/pdflatex -synctex=1 -interaction=nonstopmode/\" -pdf %.tex").toString();
4788 sweave_command=config->value("Tools/Sweave","R CMD Sweave %.Rnw").toString();
4789 texdoc_command=config->value("Tools/Texdoc","texdoc").toString();
4790 htlatex_command=config->value("Tools/Htlatex","htlatex").toString();
4791
4792 x11style=config->value( "X11/Style","Fusion").toString();
4793 if (xf.contains("DejaVu Sans",Qt::CaseInsensitive)) deft="DejaVu Sans";
4794 else if (xf.contains("DejaVu Sans LGC",Qt::CaseInsensitive)) deft="DejaVu Sans LGC";
4795 else if (xf.contains("Bitstream Vera Sans",Qt::CaseInsensitive)) deft="Bitstream Vera Sans";
4796 else if (xf.contains("Luxi Sans",Qt::CaseInsensitive)) deft="Luxi Sans";
4797 else deft=qApp->font().family();
4798 x11fontfamily=config->value("X11/Font Family",deft).toString();
4799 x11fontsize=config->value( "X11/Font Size","10").toInt();
4800
4801 #ifdef AUTHORIZE_LINUX_QSTYLES
4802 if(desktop_env == 1)
4803 {
4804 if (styles.contains("GTK+")) qApp->setStyle(QLatin1String("gtkstyle"));
4805 else if (styles.contains("Breeze")) qApp->setStyle(QLatin1String("breeze"));
4806 else qApp->setStyle(QLatin1String("fusion"));
4807 }
4808 else if (styles.contains("Breeze")) qApp->setStyle(QLatin1String("breeze"));
4809 else qApp->setStyle(QLatin1String("fusion"));
4810 #else
4811 qApp->setStyle(QLatin1String("fusion"));
4812 #endif
4813 // QApplication::setPalette(QApplication::style()->standardPalette());
4814 QFont x11Font (x11fontfamily,x11fontsize);
4815 QApplication::setFont(x11Font);
4816
4817 quick_asy_command=config->value("Tools/QuickAsy","asy -f pdf -noView %.asy|"+viewpdf_command).toString();
4818 lp_options=config->value("Tools/LP","-o fitplot").toString();
4819 #endif
4820 userquick_command=config->value("Tools/Userquick","latex -interaction=nonstopmode %.tex|bibtex %.aux|latex -interaction=nonstopmode %.tex|latex -interaction=nonstopmode %.tex|xdvi %.dvi").toString();
4821 userClassList=config->value("Tools/User Class").toStringList();
4822 userPaperList=config->value("Tools/User Paper").toStringList();
4823 userEncodingList=config->value("Tools/User Encoding").toStringList();
4824 userOptionsList=config->value("Tools/User Options").toStringList();
4825 userBabelList=config->value("Tools/User Babel").toStringList();
4826 runIndex=config->value( "Tools/Run","0").toInt();
4827 viewIndex=config->value( "Tools/View","2").toInt();
4828
4829 lastDocument=config->value("Files/Last Document","").toString();
4830 lastTemplate=config->value("Files/Last Template","").toString();
4831 #if defined(Q_OS_UNIX) && !defined(Q_OS_MAC)
4832
4833 #ifdef USB_VERSION
4834 QString scriptDir=QCoreApplication::applicationDirPath() + "/";
4835 #else
4836 QString scriptDir=PREFIX"/share/texmaker/";
4837 #endif
4838 #endif
4839
4840 #if defined(Q_OS_MAC)
4841 QString scriptDir=QCoreApplication::applicationDirPath() + "/../Resources/";
4842 #endif
4843 #if defined(Q_OS_WIN32)
4844 QString scriptDir=QCoreApplication::applicationDirPath() + "/";
4845 #endif
4846 lastScript=config->value("Files/Last Script",scriptDir).toString();
4847 recentFilesList=config->value("Files/Recent Files New").toStringList();
4848
4849 input_encoding=config->value("Files/Input Encoding","UTF-8").toString();
4850 UserMenuName[0]=config->value("User/Menu1","").toString();
4851 UserMenuTag[0]=config->value("User/Tag1","").toString();
4852 UserMenuName[1]=config->value("User/Menu2","").toString();
4853 UserMenuTag[1]=config->value("User/Tag2","").toString();
4854 UserMenuName[2]=config->value("User/Menu3","").toString();
4855 UserMenuTag[2]=config->value("User/Tag3","").toString();
4856 UserMenuName[3]=config->value("User/Menu4","").toString();
4857 UserMenuTag[3]=config->value("User/Tag4","").toString();
4858 UserMenuName[4]=config->value("User/Menu5","").toString();
4859 UserMenuTag[4]=config->value("User/Tag5","").toString();
4860 UserMenuName[5]=config->value("User/Menu6","").toString();
4861 UserMenuTag[5]=config->value("User/Tag6","").toString();
4862 UserMenuName[6]=config->value("User/Menu7","").toString();
4863 UserMenuTag[6]=config->value("User/Tag7","").toString();
4864 UserMenuName[7]=config->value("User/Menu8","").toString();
4865 UserMenuTag[7]=config->value("User/Tag8","").toString();
4866 UserMenuName[8]=config->value("User/Menu9","").toString();
4867 UserMenuTag[8]=config->value("User/Tag9","").toString();
4868 UserMenuName[9]=config->value("User/Menu10","").toString();
4869 UserMenuTag[9]=config->value("User/Tag10","").toString();
4870 UserToolName[0]=config->value("User/ToolName1","").toString();
4871 UserToolCommand[0]=config->value("User/Tool1","").toString();
4872 UserToolName[1]=config->value("User/ToolName2","").toString();
4873 UserToolCommand[1]=config->value("User/Tool2","").toString();
4874 UserToolName[2]=config->value("User/ToolName3","").toString();
4875 UserToolCommand[2]=config->value("User/Tool3","").toString();
4876 UserToolName[3]=config->value("User/ToolName4","").toString();
4877 UserToolCommand[3]=config->value("User/Tool4","").toString();
4878 UserToolName[4]=config->value("User/ToolName5","").toString();
4879 UserToolCommand[4]=config->value("User/Tool5","").toString();
4880
4881 userTagsList=config->value("User/TagList").toStringList();
4882
4883 struct_level1=config->value("Structure/Structure Level 1","part").toString();
4884 struct_level2=config->value("Structure/Structure Level 2","chapter").toString();
4885 struct_level3=config->value("Structure/Structure Level 3","section").toString();
4886 struct_level4=config->value("Structure/Structure Level 4","subsection").toString();
4887 struct_level5=config->value("Structure/Structure Level 5","subsubsection").toString();
4888
4889
4890
4891
4892 document_class=config->value("Quick/Class","article").toString();
4893 typeface_size=config->value("Quick/Typeface","10pt").toString();
4894 paper_size=config->value("Quick/Papersize","a4paper").toString();
4895 document_encoding=config->value("Quick/Encoding","utf8").toString();
4896 ams_packages=config->value( "Quick/AMS",true).toBool();
4897 makeidx_package=config->value( "Quick/MakeIndex",false).toBool();
4898 babel_package=config->value( "Quick/Babel",false).toBool();
4899
4900 QString locale = QString(QLocale::system().name()).left(2);
4901 if (locale=="en") babel_default=config->value("Quick/BabelDefault","english").toString();
4902 else if (locale=="de") babel_default=config->value("Quick/BabelDefault","german").toString();
4903 else if (locale=="fr") babel_default=config->value("Quick/BabelDefault","french").toString();
4904 else if (locale=="ru") babel_default=config->value("Quick/BabelDefault","russian").toString();
4905 else if (locale=="it") babel_default=config->value("Quick/BabelDefault","italian").toString();
4906 else if (locale=="es") babel_default=config->value("Quick/BabelDefault","spanish").toString();
4907 else if (locale=="pl") babel_default=config->value("Quick/BabelDefault","polish").toString();
4908 else if (locale=="fa") babel_default=config->value("Quick/BabelDefault","farsi").toString();
4909 else if (locale=="cz") babel_default=config->value("Quick/BabelDefault","czech").toString();
4910 else if (locale=="pt") babel_default=config->value("Quick/BabelDefault","portuguese").toString();
4911 else if (locale=="sl") babel_default=config->value("Quick/BabelDefault","slovak").toString();
4912 else if (locale=="gr") babel_default=config->value("Quick/BabelDefault","greek").toString();
4913 else if (locale=="fi") babel_default=config->value("Quick/BabelDefault","finish").toString();
4914 else if (locale=="hu") babel_default=config->value("Quick/BabelDefault","magyar").toString();
4915 else babel_default=config->value("Quick/BabelDefault","").toString();
4916
4917 geometry_package=config->value( "Quick/Geometry",false).toBool();
4918 graphicx_package=config->value( "Quick/Graphicx",false).toBool();
4919 lmodern_package=config->value( "Quick/Lmodern",false).toBool();
4920 kpfonts_package=config->value( "Quick/Kpfonts",false).toBool();
4921 fourier_package=config->value( "Quick/Fourier",false).toBool();
4922
4923 author=config->value("Quick/Author","").toString();
4924 geometry_options=config->value("Quick/GeometryOptions","left=2cm,right=2cm,top=2cm,bottom=2cm").toString();
4925
4926 beamer_theme=config->value("Beamer/Theme","Warsaw").toString();
4927 beamer_size=config->value("Beamer/Size","11pt").toString();
4928 beamer_encoding=config->value("Beamer/Encoding","utf8").toString();
4929 beamer_author=config->value("Beamer/Author","").toString();
4930 if (locale=="en") beamer_babel=config->value("Beamer/BabelDefault","english").toString();
4931 else if (locale=="de") beamer_babel=config->value("Beamer/BabelDefault","german").toString();
4932 else if (locale=="fr") beamer_babel=config->value("Beamer/BabelDefault","french").toString();
4933 else if (locale=="ru") beamer_babel=config->value("Beamer/BabelDefault","russian").toString();
4934 else if (locale=="it") beamer_babel=config->value("Beamer/BabelDefault","italian").toString();
4935 else if (locale=="es") beamer_babel=config->value("Beamer/BabelDefault","spanish").toString();
4936 else if (locale=="pl") beamer_babel=config->value("Beamer/BabelDefault","polish").toString();
4937 else if (locale=="fa") beamer_babel=config->value("Beamer/BabelDefault","farsi").toString();
4938 else if (locale=="cz") beamer_babel=config->value("Beamer/BabelDefault","czech").toString();
4939 else if (locale=="pt") beamer_babel=config->value("Beamer/BabelDefault","portuguese").toString();
4940 else if (locale=="sl") beamer_babel=config->value("Beamer/BabelDefault","slovak").toString();
4941 else if (locale=="gr") beamer_babel=config->value("Beamer/BabelDefault","greek").toString();
4942 else if (locale=="fi") beamer_babel=config->value("Beamer/BabelDefault","finish").toString();
4943 else if (locale=="hu") beamer_babel=config->value("Beamer/BabelDefault","magyar").toString();
4944 else beamer_babel=config->value("Beamer/BabelDefault","").toString();
4945
4946
4947 #if defined(Q_OS_UNIX) && !defined(Q_OS_MAC)
4948
4949 #ifdef USB_VERSION
4950 QString dicDir=QCoreApplication::applicationDirPath() + "/";
4951 #else
4952 #ifdef DEBIAN_SPELLDIR
4953 QString dicDir=PREFIX"/share/myspell/dicts/";
4954 #else
4955 QString dicDir=PREFIX"/share/texmaker/";
4956 #endif
4957 #endif
4958
4959 #endif
4960 #if defined(Q_OS_MAC)
4961 QString dicDir=QCoreApplication::applicationDirPath() + "/../Resources/";
4962 #endif
4963 #if defined(Q_OS_WIN32)
4964 QString dicDir=QCoreApplication::applicationDirPath() + "/";
4965 #endif
4966 QString defaultDic=dicDir+QString(QLocale::system().name())+".dic";
4967 QFileInfo fi(defaultDic);
4968 if (!fi.exists() || !fi.isReadable()) defaultDic=dicDir+"en_GB.dic";
4969 spell_dic=config->value("Spell/Dic",defaultDic).toString();
4970 QFileInfo fispell(spell_dic);
4971 pdfCheckerLang=fispell.fileName().left(2);
4972 if (!pdfCheckerLang.contains(QRegExp("(de|en|es|fr|id|it|nl|pl|pt|ru)"))) pdfCheckerLang="en";
4973
4974 spell_ignored_words=config->value("Spell/Words","").toString();
4975 inlinespellcheck=config->value( "Spell/Inline",true).toBool();
4976 for (int i=0; i <412 ; i++)
4977 {
4978 symbolScore[i]=config->value( "Symbols/symbol"+QString::number(i),0).toInt();
4979 }
4980 favoriteSymbolList.clear();
4981 QList<QVariant> favoriteSymbolSettings = config->value( "Symbols/Favorites" ).toList( );
4982 if( !favoriteSymbolSettings.isEmpty())
4983 {
4984 for( int i = 0; i < favoriteSymbolSettings.count( ); i++ ) favoriteSymbolList.append(favoriteSymbolSettings.at(i).toInt());
4985 }
4986
4987
4988
4989 colorBackground=config->value("Color/Background",QColor("#FFFFFF")).value<QColor>();
4990 colorLine=config->value("Color/Line",QColor("#ececec")).value<QColor>();
4991 colorHighlight=config->value("Color/Highlight",QColor("#FF0000")).value<QColor>();
4992 colorStandard=config->value("Color/Standard",QColor("#000000")).value<QColor>();
4993 colorComment=config->value("Color/Comment",QColor("#606060")).value<QColor>();
4994 colorMath=config->value("Color/Math",QColor("#008000")).value<QColor>();
4995 colorCommand=config->value("Color/Command",QColor("#800000")).value<QColor>();
4996 colorKeyword=config->value("Color/Keyword",QColor("#0000CC")).value<QColor>();
4997 colorVerbatim=config->value("Color/Verbatim",QColor("#9A4D00")).value<QColor>();
4998 colorTodo=config->value("Color/Todo",QColor("#FF0000")).value<QColor>();
4999 colorKeywordGraphic=config->value("Color/KeywordGraphic",QColor("#006699")).value<QColor>();
5000 colorNumberGraphic=config->value("Color/NumberGraphic",QColor("#660066")).value<QColor>();
5001
5002 config->endGroup();
5003 }
5004
SaveSettings()5005 void Texmaker::SaveSettings()
5006 {
5007 SaveLastSession();
5008 #ifdef USB_VERSION
5009 QSettings config(QCoreApplication::applicationDirPath()+"/texmaker.ini",QSettings::IniFormat); //for USB-stick version
5010 #else
5011 QSettings config(QSettings::IniFormat,QSettings::UserScope,"xm1","texmaker");
5012 #endif
5013
5014 config.setValue( "IniMode",true);
5015 config.beginGroup( "texmaker" );
5016 QList<int> sizes;
5017 QList<int>::Iterator it;
5018
5019 config.setValue( "GUI/Style",modern_style);
5020 config.setValue( "GUI/New Version",true);
5021 #if defined(Q_OS_UNIX) && !defined(Q_OS_MAC)
5022 config.setValue( "X11/Style",x11style);
5023 config.setValue("X11/Font Family",x11fontfamily);
5024 config.setValue( "X11/Font Size",x11fontsize);
5025 #endif
5026
5027 config.setValue("MainWindowState",saveState(0));
5028 config.setValue("MainWindowMaximized",windowState().testFlag(Qt::WindowMaximized));
5029 config.setValue("Splitter1State",splitter1->saveState());
5030 config.setValue("Splitter2State",splitter2->saveState());
5031 config.setValue("Splitter3State",splitter3->saveState());
5032 config.setValue("Geometries/MainwindowWidth", width() );
5033 config.setValue("Geometries/MainwindowHeight", height() );
5034 config.setValue("Geometries/MainwindowX", x() );
5035 config.setValue("Geometries/MainwindowY", y() );
5036
5037 config.setValue("Print/PaperSize",psize);
5038 int pscale=10;
5039 if (builtinpdfview)
5040 {
5041 if (pdfviewerWindow) pscale= (int) (pdfviewerWindow->getScale()*100);
5042 if (embedinternalpdf && pdfviewerWidget) pscale= (int) (pdfviewerWidget->getScale()*100);
5043 }
5044
5045 config.setValue("PdfView/Scale",pscale);
5046
5047 config.setValue("Editor/Font Family",EditorFont.family());
5048 config.setValue( "Editor/Font Size",EditorFont.pointSize());
5049
5050 config.setValue( "Editor/TabSpaces",tabspaces);
5051 config.setValue( "Editor/TabWidth",tabwidth);
5052 config.setValue( "Editor/WordWrap",wordwrap);
5053 config.setValue( "Editor/Watcher",watchfiles);
5054 config.setValue( "Editor/AutoSave",autosave);
5055 config.setValue( "Editor/Parentheses Matching",parenmatch);
5056 config.setValue( "Editor/Line Numbers",showline);
5057 config.setValue( "Editor/Completion",completion);
5058 config.setValue( "Editor/UserCompletion",userCompletionList);
5059 config.setValue( "Editor/SvnEnable",svnEnable);
5060 config.setValue( "Editor/SvnPath",svnPath);
5061 QStringList data,shortcut;
5062 // data.clear();
5063 // shortcut.clear();
5064 KeysMap::Iterator its;
5065
5066 for( its = shortcuts.begin(); its != shortcuts.end(); ++its )
5067 {
5068 data.append(its.key());
5069 shortcut.append(its.value());
5070 }
5071 config.setValue("Shortcuts/data",data);
5072 config.setValue("Shortcuts/shortcut",shortcut);
5073 config.setValue("Shortcuts/togglefocus",keyToggleFocus);
5074
5075 config.setValue("Show/OutputView",showoutputview);
5076 config.setValue( "Show/Structureview",showstructview);
5077 config.setValue( "Show/Pdfview",showpdfview);
5078 config.setValue( "Show/Sourceview",showsourceview);
5079 config.setValue( "Show/Filesview",showfilesview);
5080
5081 config.setValue( "Show/Pstricks",showPstricks);
5082 config.setValue( "Show/Metapost",showMp);
5083 config.setValue( "Show/Tikz",showTikz);
5084 config.setValue( "Show/Asymptote",showAsy);
5085
5086 config.setValue( "Show/Emphasis",showEmphasis);
5087 config.setValue( "Show/Newline",showNewline);
5088 config.setValue( "Show/Mathmode",showMathmode);
5089 config.setValue( "Show/Indice",showIndice);
5090 config.setValue( "Show/Puissance",showPuissance);
5091 config.setValue( "Show/Smallfrac",showSmallfrac);
5092 config.setValue( "Show/Dfrac",showDfrac);
5093 config.setValue( "Show/Racine",showRacine);
5094
5095 config.setValue("Tools/ExtraPath",extra_path);
5096 config.setValue("Tools/OutputDir",useoutputdir);
5097 config.setValue("Tools/CleanWhenExit",clean_exit);
5098
5099 config.setValue("Tools/Quick Mode",quickmode);
5100 config.setValue("Tools/Latex",latex_command);
5101 config.setValue("Tools/Dvi",viewdvi_command);
5102 config.setValue("Tools/Dvips",dvips_command);
5103 config.setValue("Tools/Ps",viewps_command);
5104 config.setValue("Tools/Ps2pdf",ps2pdf_command);
5105 config.setValue("Tools/Makeindex",makeindex_command);
5106 config.setValue("Tools/Bibtex",bibtex_command);
5107 config.setValue("Tools/Pdflatex",pdflatex_command);
5108 config.setValue("Tools/Xelatex",xelatex_command);
5109 config.setValue("Tools/Lualatex",lualatex_command);
5110 config.setValue("Tools/Pdf",viewpdf_command);
5111 config.setValue("Tools/Dvipdf",dvipdf_command);
5112 config.setValue("Tools/Metapost",metapost_command);
5113 config.setValue("Tools/Ghostscript",ghostscript_command);
5114 config.setValue("Tools/Asymptote",asymptote_command);
5115 config.setValue("Tools/Latexmk",latexmk_command);
5116 config.setValue("Tools/Sweave",sweave_command);
5117 config.setValue("Tools/Texdoc",texdoc_command);
5118 config.setValue("Tools/HtOptions",htlatex_options);
5119 config.setValue("Tools/Htlatex",htlatex_command);
5120 config.setValue("Tools/Userquick",userquick_command);
5121 config.setValue("Tools/QuickAsy",quick_asy_command);
5122 config.setValue("Tools/LP",lp_options);
5123
5124 if (userClassList.count()>0) config.setValue("Tools/User Class",userClassList);
5125 if (userPaperList.count()>0) config.setValue("Tools/User Paper",userPaperList);
5126 if (userEncodingList.count()>0) config.setValue("Tools/User Encoding",userEncodingList);
5127 if (userOptionsList.count()>0) config.setValue("Tools/User Options",userOptionsList);
5128 if (userBabelList.count()>0) config.setValue("Tools/User Babel",userBabelList);
5129 config.setValue( "Tools/Run",comboCompil->currentIndex());
5130 config.setValue( "Tools/View",comboView->currentIndex());
5131 config.setValue("Tools/IntegratedPdfViewer",builtinpdfview);
5132 config.setValue("Tools/PdfInternalViewEmbed",embedinternalpdf);
5133 config.setValue("Tools/SingleViewerInstance",singleviewerinstance);
5134
5135
5136 config.setValue("Files/Last Document",lastDocument);
5137 config.setValue("Files/Last Template",lastTemplate);
5138 config.setValue("Files/Last Script",lastScript);
5139 /*if (recentFilesList.count()>0)*/ config.setValue("Files/Recent Files New",recentFilesList);
5140
5141 config.setValue("Files/Input Encoding", input_encoding);
5142
5143 config.setValue("User/Menu1",UserMenuName[0]);
5144 config.setValue("User/Tag1",UserMenuTag[0]);
5145 config.setValue("User/Menu2",UserMenuName[1]);
5146 config.setValue("User/Tag2",UserMenuTag[1]);
5147 config.setValue("User/Menu3",UserMenuName[2]);
5148 config.setValue("User/Tag3",UserMenuTag[2]);
5149 config.setValue("User/Menu4",UserMenuName[3]);
5150 config.setValue("User/Tag4",UserMenuTag[3]);
5151 config.setValue("User/Menu5",UserMenuName[4]);
5152 config.setValue("User/Tag5",UserMenuTag[4]);
5153 config.setValue("User/Menu6",UserMenuName[5]);
5154 config.setValue("User/Tag6",UserMenuTag[5]);
5155 config.setValue("User/Menu7",UserMenuName[6]);
5156 config.setValue("User/Tag7",UserMenuTag[6]);
5157 config.setValue("User/Menu8",UserMenuName[7]);
5158 config.setValue("User/Tag8",UserMenuTag[7]);
5159 config.setValue("User/Menu9",UserMenuName[8]);
5160 config.setValue("User/Tag9",UserMenuTag[8]);
5161 config.setValue("User/Menu10",UserMenuName[9]);
5162 config.setValue("User/Tag10",UserMenuTag[9]);
5163 config.setValue("User/ToolName1",UserToolName[0]);
5164 config.setValue("User/Tool1",UserToolCommand[0]);
5165 config.setValue("User/ToolName2",UserToolName[1]);
5166 config.setValue("User/Tool2",UserToolCommand[1]);
5167 config.setValue("User/ToolName3",UserToolName[2]);
5168 config.setValue("User/Tool3",UserToolCommand[2]);
5169 config.setValue("User/ToolName4",UserToolName[3]);
5170 config.setValue("User/Tool4",UserToolCommand[3]);
5171 config.setValue("User/ToolName5",UserToolName[4]);
5172 config.setValue("User/Tool5",UserToolCommand[4]);
5173
5174 config.setValue("User/TagList",userTagsList);
5175
5176 config.setValue("Structure/Structure Level 1",struct_level1);
5177 config.setValue("Structure/Structure Level 2",struct_level2);
5178 config.setValue("Structure/Structure Level 3",struct_level3);
5179 config.setValue("Structure/Structure Level 4",struct_level4);
5180 config.setValue("Structure/Structure Level 5",struct_level5);
5181
5182 config.setValue( "Quick/Class",document_class);
5183 config.setValue( "Quick/Typeface",typeface_size);
5184 config.setValue( "Quick/Papersize",paper_size);
5185 config.setValue( "Quick/Encoding",document_encoding);
5186 config.setValue( "Quick/AMS",ams_packages);
5187 config.setValue( "Quick/MakeIndex",makeidx_package);
5188 config.setValue( "Quick/Babel",babel_package);
5189 config.setValue( "Quick/BabelDefault",babel_default);
5190 config.setValue( "Quick/Geometry",geometry_package);
5191 config.setValue( "Quick/Graphicx",graphicx_package);
5192 config.setValue( "Quick/Lmodern",lmodern_package);
5193 config.setValue( "Quick/Kpfonts",kpfonts_package);
5194 config.setValue( "Quick/Fourier",fourier_package);
5195
5196
5197
5198 config.setValue( "Quick/Author",author);
5199 config.setValue( "Quick/GeometryOptions",geometry_options);
5200
5201 config.setValue( "Beamer/Theme",beamer_theme);
5202 config.setValue( "Beamer/Size",beamer_size);
5203 config.setValue( "Beamer/Encoding",beamer_encoding);
5204 config.setValue( "Beamer/Author",beamer_author);
5205 config.setValue( "Beamer/BabelDefault",beamer_babel);
5206
5207 config.setValue( "Spell/Dic",spell_dic);
5208 config.setValue( "Spell/Words",spell_ignored_words);
5209 config.setValue( "Spell/Inline",inlinespellcheck);
5210
5211 for (int i=0; i <412 ; i++)
5212 {
5213 config.setValue( "Symbols/symbol"+QString::number(i),symbolScore[i]);
5214 }
5215 QList<QVariant> favoriteSymbolSettings;
5216 if( !favoriteSymbolList.isEmpty())
5217 {
5218 for( int i = 0; i < favoriteSymbolList.count( ); i++ ) favoriteSymbolSettings.append(favoriteSymbolList.at(i));
5219 }
5220 config.setValue("Symbols/Favorites",favoriteSymbolSettings);
5221 config.setValue("Color/Background",colorBackground);
5222 config.setValue("Color/Line",colorLine);
5223 config.setValue("Color/Highlight",colorHighlight);
5224 config.setValue("Color/Standard",colorStandard);
5225 config.setValue("Color/Comment",colorComment);
5226 config.setValue("Color/Math",colorMath);
5227 config.setValue("Color/Command",colorCommand);
5228 config.setValue("Color/Keyword",colorKeyword);
5229 config.setValue("Color/Verbatim",colorVerbatim);
5230 config.setValue("Color/Todo",colorTodo);
5231 config.setValue("Color/KeywordGraphic",colorKeywordGraphic);
5232 config.setValue("Color/NumberGraphic",colorNumberGraphic);
5233
5234
5235 config.endGroup();
5236 }
5237
DeleteSettings()5238 void Texmaker::DeleteSettings()
5239 {
5240 switch( QMessageBox::warning(this, "Texmaker",
5241 tr("Delete settings file?\n(Texmaker will be closed and you will have to restart it)"),
5242 tr("Ok"), tr("Cancel"),
5243 0,
5244 1 ) )
5245 {
5246 case 0:
5247 eraseSettings=true;
5248 fileExit();
5249 break;
5250 case 1:
5251 default:
5252 return;
5253 break;
5254 }
5255 }
5256
CopySettings()5257 void Texmaker::CopySettings()
5258 {
5259 QFileInfo fi_or(settingsFileName);
5260 if (fi_or.exists())
5261 {
5262 QFile fichier_or(settingsFileName);
5263 QString to_file = QFileDialog::getSaveFileName(this,tr("Save As"),QDir::homePath(),"Setting files (*.ini);;All files (*.*)");
5264 if ( !to_file.isEmpty() )
5265 {
5266 QFileInfo fi_dest(to_file);
5267 if (fi_dest.exists())
5268 {
5269 QFile fichier_dest(to_file);
5270 fichier_dest.remove();
5271 fichier_or.copy(to_file);
5272 }
5273 else
5274 {
5275 fichier_or.copy(to_file);
5276 }
5277 }
5278 }
5279 }
5280
ReplaceSettings()5281 void Texmaker::ReplaceSettings()
5282 {
5283 switch( QMessageBox::warning(this, "Texmaker",
5284 tr("Replace settings file by a new one?\n(Texmaker will be closed and you will have to restart it)"),
5285 tr("Ok"), tr("Cancel"),
5286 0,
5287 1 ) )
5288 {
5289 case 0:
5290 replaceSettings=true;
5291 fileExit();
5292 break;
5293 case 1:
5294 default:
5295 return;
5296 break;
5297 }
5298 }
5299
setPrintPaperSize(const QString & p)5300 void Texmaker::setPrintPaperSize(const QString &p)
5301 {
5302 psize=p;
5303 }
5304
5305 ////////////////// STRUCTURE ///////////////////
ShowOpenedFiles()5306 void Texmaker::ShowOpenedFiles()
5307 {
5308 LeftPanelStackedWidget->setCurrentWidget(OpenedFilesListWidget);
5309 titleLeftPanel->setText(tr("Opened Files").toUpper());
5310 }
5311
OpenedFileActivated(QListWidgetItem * item)5312 void Texmaker::OpenedFileActivated(QListWidgetItem *item)
5313 {
5314 int index=OpenedFilesListWidget->currentRow();
5315 disconnect(comboFiles, SIGNAL(activated(int)), this, SLOT(listSelectionActivated(int)));
5316 if ((index>-1) && (index<comboFiles->count())) comboFiles->setCurrentIndex(index);
5317 connect(comboFiles, SIGNAL(activated(int)), this, SLOT(listSelectionActivated(int)));
5318 QString f=comboFiles->itemData(index, Qt::UserRole).toString();
5319 FilesMap::Iterator it;
5320 QString fw32,funix,forig;
5321 for( it = filenames.begin(); it != filenames.end(); ++it )
5322 {
5323 forig=filenames[it.key()];
5324 fw32=filenames[it.key()];
5325 funix=filenames[it.key()];
5326 fw32.replace(QString("\\"),QString("/"));
5327 funix.replace(QString("/"),QString("\\"));
5328 if ( (forig==f) || (fw32==f) || (funix==f))
5329 {
5330 EditorView->setCurrentIndex(EditorView->indexOf(it.key()));
5331 }
5332 }
5333 }
ShowStructure()5334 void Texmaker::ShowStructure()
5335 {
5336 LeftPanelStackedWidget->setCurrentWidget(StructureTreeWidget);
5337 titleLeftPanel->setText(tr("Structure").toUpper());
5338 }
ShowRelation()5339 void Texmaker::ShowRelation() //RelationListWidget
5340 {
5341 LeftPanelStackedWidget->setCurrentWidget(RelationListWidget);
5342 titleLeftPanel->setText(tr("Relation symbols").toUpper());
5343 }
ShowArrow()5344 void Texmaker::ShowArrow() //ArrowListWidget
5345 {
5346 LeftPanelStackedWidget->setCurrentWidget(ArrowListWidget);
5347 titleLeftPanel->setText(tr("Arrow symbols").toUpper());
5348 }
ShowMisc()5349 void Texmaker::ShowMisc() //MiscellaneousListWidget
5350 {
5351 LeftPanelStackedWidget->setCurrentWidget(MiscellaneousListWidget);
5352 titleLeftPanel->setText(tr("Miscellaneous symbols").toUpper());
5353 }
ShowDelim()5354 void Texmaker::ShowDelim() //DelimitersListWidget
5355 {
5356 LeftPanelStackedWidget->setCurrentWidget(DelimitersListWidget);
5357 titleLeftPanel->setText(tr("Delimiters").toUpper());
5358 }
ShowGreek()5359 void Texmaker::ShowGreek() //GreekListWidget
5360 {
5361 LeftPanelStackedWidget->setCurrentWidget(GreekListWidget);
5362 titleLeftPanel->setText(tr("Greek letters").toUpper());
5363 }
ShowMostUsed()5364 void Texmaker::ShowMostUsed() //MostUsedListWidget
5365 {
5366 LeftPanelStackedWidget->setCurrentWidget(MostUsedListWidget);
5367 titleLeftPanel->setText(tr("Most used symbols").toUpper());
5368 }
ShowFavorite()5369 void Texmaker::ShowFavorite() //FavoriteListWidget
5370 {
5371 LeftPanelStackedWidget->setCurrentWidget(FavoriteListWidget);
5372 titleLeftPanel->setText(tr("Favorites symbols").toUpper());
5373 }
ShowPstricks()5374 void Texmaker::ShowPstricks() //PsListWidget
5375 {
5376 LeftPanelStackedWidget->setCurrentWidget(PsListWidget);
5377 titleLeftPanel->setText(tr("Pstricks Commands").toUpper());
5378 }
ShowLeftRight()5379 void Texmaker::ShowLeftRight() //leftrightWidget
5380 {
5381 LeftPanelStackedWidget->setCurrentWidget(leftrightWidget);
5382 titleLeftPanel->setText(QString("left/right").toUpper());
5383 }
ShowMplist()5384 void Texmaker::ShowMplist() //MpListWidget
5385 {
5386 LeftPanelStackedWidget->setCurrentWidget(MpListWidget);
5387 titleLeftPanel->setText(tr("MetaPost Commands").toUpper());
5388 }
ShowTikz()5389 void Texmaker::ShowTikz() //TikzWidget
5390 {
5391 LeftPanelStackedWidget->setCurrentWidget(tikzWidget);
5392 titleLeftPanel->setText(tr("Tikz Commands").toUpper());
5393 }
ShowAsy()5394 void Texmaker::ShowAsy() //AsyWidget
5395 {
5396 LeftPanelStackedWidget->setCurrentWidget(asyWidget);
5397 titleLeftPanel->setText(tr("Asymptote Commands").toUpper());
5398 }
5399
ShowUserPanel()5400 void Texmaker::ShowUserPanel()
5401 {
5402 LeftPanelStackedWidget->setCurrentWidget(usertagsListWidget);
5403 titleLeftPanel->setText(tr("User").toUpper());
5404 }
5405
UpdateStructure()5406 void Texmaker::UpdateStructure()
5407 {
5408 QFont deft=QFont("DejaVu Sans Condensed",qApp->font().pointSize());
5409
5410 QTreeWidgetItem *Child,*parent_level[5], *theitem;
5411 QString current;
5412 if (StructureTreeWidget->currentItem()) current=StructureTreeWidget->currentItem()->text(0);
5413
5414 if ( !currentEditorView() )
5415 {
5416 StructureTreeWidget->clear();
5417 return;
5418 }
5419
5420 QString shortName = getName();
5421 if ((shortName.right(4)!=".tex") && (shortName.right(4)!=".Rnw") && (!shortName.startsWith("untitled"))) return;
5422 /*************************************/
5423 QList<QTreeWidgetItem *> fItems;
5424 bool islabels_expanded=false;
5425 bool isblocks_expanded=true;
5426 fItems=StructureTreeWidget->findItems ("LABELS",Qt::MatchRecursive,0);
5427 if (fItems.size()>0 )
5428 {
5429 if (fItems.at(0))
5430 {
5431 islabels_expanded=fItems.at(0)->isExpanded();
5432 }
5433 }
5434 fItems.clear();
5435 fItems=StructureTreeWidget->findItems ("BLOCKS",Qt::MatchRecursive,0);
5436 if (fItems.size()>0 )
5437 {
5438 if (fItems.at(0))
5439 {
5440 isblocks_expanded=fItems.at(0)->isExpanded();
5441 }
5442 }
5443 /*************************************/
5444 StructureTreeWidget->clear();
5445 int pos;
5446 while ( (pos = (int)shortName.indexOf('/')) != -1 )
5447 shortName.remove(0,pos+1);
5448 QTreeWidgetItem *top = new QTreeWidgetItem(StructureTreeWidget);
5449 top->setIcon(0,getIcon(":/images/doc.png"));
5450 top->setText(0,shortName);
5451 top->setFont(0,deft);
5452 Child=parent_level[0]=parent_level[1]=parent_level[2]=parent_level[3]=parent_level[4]=top;
5453 labelitem.clear();
5454 if (singlemode)
5455 {
5456 listbibfiles.clear();
5457 listchildfiles.clear();
5458 }
5459 QTreeWidgetItem *toplabel = new QTreeWidgetItem(top);
5460 toplabel->setText(0,"LABELS");
5461 toplabel->setFont(0,deft);
5462 QTreeWidgetItem *blocklabel = new QTreeWidgetItem(top);
5463 blocklabel->setText(0,"BLOCKS");
5464 blocklabel->setFont(0,deft);
5465 QString s;
5466 QTextBlock p = currentEditorView()->editor->document()->begin();
5467 const QList<StructItem>& structure = currentEditorView()->editor->getStructItems();
5468 //int i;
5469 for (int j = 0; j < structure.count(); j++)
5470 {
5471 //i=structure.at(j).cursor.block().blockNumber();
5472 switch (structure.at(j).type)
5473 {
5474 case 0:
5475 {
5476 s=structure.at(j).item;
5477 Child = new QTreeWidgetItem(blocklabel);
5478 Child->setText(0,s);
5479 Child->setFont(0,deft);
5480 Child->setText(1,QString::number(j));
5481 StructureTreeWidget->expandItem(Child);
5482 }break;
5483 case 1:
5484 {
5485 s=structure.at(j).item;
5486 labelitem.append(s);
5487 Child = new QTreeWidgetItem(toplabel);
5488 Child->setText(0,s);
5489 Child->setFont(0,deft);
5490 Child->setText(1,QString::number(j));
5491 StructureTreeWidget->expandItem(Child);
5492 }break;
5493 case 2:
5494 {
5495 s=structure.at(j).item;
5496 Child = new QTreeWidgetItem(top);
5497 Child->setText(0,s);
5498 Child->setFont(0,deft);
5499 Child->setText(1,QString::number(j));
5500 Child->setIcon(0,getIcon(":/images/include.png"));
5501 if (listchildfiles.indexOf(s)<0) addIncludeFiles(s);
5502 }break;
5503 case 3:
5504 {
5505 s=structure.at(j).item;
5506 Child = new QTreeWidgetItem(top);
5507 Child->setText(0,s);
5508 Child->setFont(0,deft);
5509 Child->setText(1,QString::number(j));
5510 Child->setIcon(0,getIcon(":/images/include.png"));
5511 if (listchildfiles.indexOf(s)<0) addIncludeFiles(s);
5512 }break;
5513 case 4:
5514 {
5515 s=structure.at(j).item;
5516 parent_level[0] = new QTreeWidgetItem(top);
5517 parent_level[0]->setText(0,s);
5518 parent_level[0]->setFont(0,deft);
5519 parent_level[0]->setText(1,QString::number(j));
5520 parent_level[0]->setIcon(0,getIcon(":/images/part.png"));
5521 StructureTreeWidget->expandItem(parent_level[0]);
5522 parent_level[1]=parent_level[2]=parent_level[3]=parent_level[4]=parent_level[0];
5523 }break;
5524 case 5:
5525 {
5526 s=structure.at(j).item;
5527 parent_level[1] = new QTreeWidgetItem(parent_level[0]);
5528 parent_level[1]->setText(0,s);
5529 parent_level[1]->setFont(0,deft);
5530 parent_level[1]->setText(1,QString::number(j));
5531 parent_level[1]->setIcon(0,getIcon(":/images/chapter.png"));
5532 StructureTreeWidget->expandItem(parent_level[1]);
5533 parent_level[2]=parent_level[3]=parent_level[4]=parent_level[1];
5534 }break;
5535 case 6:
5536 {
5537 s=structure.at(j).item;
5538 parent_level[2] = new QTreeWidgetItem(parent_level[1]);
5539 parent_level[2]->setText(0,s);
5540 parent_level[2]->setFont(0,deft);
5541 parent_level[2]->setText(1,QString::number(j));
5542 parent_level[2]->setIcon(0,getIcon(":/images/section.png"));
5543 StructureTreeWidget->expandItem(parent_level[2]);
5544 parent_level[3]=parent_level[4]=parent_level[2];
5545 }break;
5546 case 7:
5547 {
5548 s=structure.at(j).item;
5549 parent_level[3] = new QTreeWidgetItem(parent_level[2]);
5550 parent_level[3]->setText(0,s);
5551 parent_level[3]->setFont(0,deft);
5552 parent_level[3]->setText(1,QString::number(j));
5553 //parent_level[3]->setIcon(0,getIcon(":/images/subsection.png"));
5554 parent_level[4]=parent_level[3];
5555 }break;
5556 case 8:
5557 {
5558 s=structure.at(j).item;
5559 parent_level[4] = new QTreeWidgetItem(parent_level[3]);
5560 parent_level[4]->setText(0,s);
5561 parent_level[4]->setFont(0,deft);
5562 parent_level[4]->setText(1,QString::number(j));
5563 //parent_level[4]->setIcon(0,getIcon(":/images/subsubsection.png"));
5564 }break;
5565 case 9:
5566 {
5567 s=structure.at(j).item;
5568 Child = new QTreeWidgetItem(top);
5569 Child->setText(0,s);
5570 Child->setFont(0,deft);
5571 Child->setText(1,QString::number(j));
5572 Child->setIcon(0,getIcon(":/images/include.png"));
5573 if (listbibfiles.indexOf(s)<0) addBibFiles(s);
5574 }break;
5575 }
5576 }
5577
5578 if (!current.isEmpty())
5579 {
5580 QList<QTreeWidgetItem *> fItems=StructureTreeWidget->findItems (current,Qt::MatchRecursive,0);
5581 if ((fItems.size()>0 ) && (fItems.at(0)))
5582 {
5583 StructureTreeWidget->setCurrentItem(fItems.at(0));
5584 theitem=fItems.at(0)->parent();
5585 while ((theitem) && (theitem!=top))
5586 {
5587 StructureTreeWidget->expandItem(theitem);
5588 theitem=theitem->parent();
5589 }
5590 }
5591 }
5592 StructureTreeWidget->setItemExpanded (top,true);
5593 //StructureTreeWidget->setItemExpanded (toplabel,false);
5594 //StructureTreeWidget->setItemExpanded (blocklabel,true);
5595 /*************************************************/
5596 fItems.clear();
5597 fItems=StructureTreeWidget->findItems ("LABELS",Qt::MatchRecursive,0);
5598 if (fItems.size()>0 )
5599 {
5600 if (fItems.at(0))
5601 {
5602 StructureTreeWidget->setItemExpanded(fItems.at(0),islabels_expanded);
5603 }
5604 }
5605 fItems.clear();
5606 fItems=StructureTreeWidget->findItems ("BLOCKS",Qt::MatchRecursive,0);
5607 if (fItems.size()>0 )
5608 {
5609 if (fItems.at(0))
5610 {
5611 StructureTreeWidget->setItemExpanded (fItems.at(0),isblocks_expanded);
5612 }
5613 }
5614
5615 /************************************************/
5616
5617 currentEditorView()->editor->foldableLines.clear();
5618 int endpreamble = currentEditorView()->editor->searchLine("\\begin{document}");
5619 if (endpreamble>1) currentEditorView()->editor->foldableLines.insert(0,endpreamble-1);
5620 ParseTree(top);
5621 UpdateChildsLabels(listchildfiles);
5622 updateCompleter();
5623 if (currentEditorView())
5624 {
5625 if (completion) currentEditorView()->editor->setCompleter(completer);
5626 else currentEditorView()->editor->setCompleter(0);
5627 currentEditorView()->editor->matchAll();
5628 }
5629 }
5630
UpdateChildsLabels(QStringList listfiles)5631 void Texmaker::UpdateChildsLabels(QStringList listfiles)
5632 {
5633 if ( !currentEditorView() ) return;
5634 QString shortName = getName();
5635 if ((shortName.right(4)!=".tex") && (!shortName.startsWith("untitled"))) return;
5636 //currentEditorView()->editor->highlighter->rehighlight();
5637 int pos;
5638 while ( (pos = (int)shortName.indexOf('/')) != -1 )
5639 shortName.remove(0,pos+1);
5640 /*********/
5641 QString finame;
5642 if (singlemode) {finame=getName();}
5643 else {finame=MasterName;}
5644 QFileInfo fi(finame);
5645 QString name=fi.absoluteFilePath();
5646 QString flname=fi.fileName();
5647 QString basename=name.left(name.length()-flname.length());
5648 if (listfiles.count()>0)
5649 {
5650 QString fname;
5651 QRegExp macroName("\\label\\{(.*)\\}", Qt::CaseInsensitive);
5652 macroName.setMinimal(true);
5653 QString line;
5654 for ( int i = 0; i <listfiles.count(); i++ )
5655 {
5656 fname=listfiles.at(i);
5657 QFileInfo fi(fname);
5658 if (fi.exists() && fi.isReadable())
5659 {
5660 QFile f(fname);
5661 if ( f.open(QIODevice::ReadOnly) )
5662 {
5663 QTextStream t( &f );
5664 while ( !t.atEnd() )
5665 {
5666 line=t.readLine();
5667 line=line.simplified();
5668 if (!line.isEmpty())
5669 {
5670 if (macroName.indexIn(line)>-1) {labelitem.append(macroName.cap(1).trimmed());}
5671 }
5672 }
5673 }
5674 f.close();
5675 }
5676 }
5677 }
5678 }
5679
UpdateBibliography()5680 void Texmaker::UpdateBibliography()
5681 {
5682 if ( !currentEditorView() ) return;
5683 bibitem.clear();
5684 if (listbibfiles.count()>0)
5685 {
5686 QString fname;
5687 QStringList types;
5688 types << QLatin1String("article") << QLatin1String("book")
5689 << QLatin1String("booklet") << QLatin1String("inbook")
5690 << QLatin1String("incollection") << QLatin1String("inproceedings")
5691 << QLatin1String("manual") << QLatin1String("mastersthesis")
5692 << QLatin1String("misc") << QLatin1String("phdthesis")
5693 << QLatin1String("proceedings") << QLatin1String("techreport")
5694 << QLatin1String("unpublished") << QLatin1String("periodical")
5695 << QLatin1String("conference") << QLatin1String("mvbook")
5696 << QLatin1String("collection") << QLatin1String("mvcollection")
5697 << QLatin1String("online") << QLatin1String("mvproceedings")
5698 << QLatin1String("inproceedings") << QLatin1String("report")
5699 << QLatin1String("thesis") << QLatin1String("electronic") << QLatin1String("patent");
5700 QRegExp macroName("@("+types.join("|")+")\\s*\\{\\s*(.*),", Qt::CaseInsensitive);
5701 macroName.setMinimal(true);
5702 QString line;
5703 for ( int i = 0; i <listbibfiles.count(); i++ )
5704 {
5705 fname=listbibfiles.at(i);
5706 QFileInfo fi(fname);
5707 if (fi.exists() && fi.isReadable())
5708 {
5709 QFile f(fname);
5710 if ( f.open(QIODevice::ReadOnly) )
5711 {
5712 QTextStream t( &f );
5713 while ( !t.atEnd() )
5714 {
5715 line=t.readLine();
5716 line=line.simplified();
5717 if (!line.isEmpty())
5718 {
5719 if (macroName.indexIn(line)>-1) bibitem.append(macroName.cap(2).trimmed());
5720 }
5721 }
5722 }
5723 f.close();
5724 }
5725 }
5726 }
5727 /************/
5728 updateCompleter();
5729 if (currentEditorView())
5730 {
5731 if (completion) currentEditorView()->editor->setCompleter(completer);
5732 else currentEditorView()->editor->setCompleter(0);
5733 currentEditorView()->editor->matchAll();
5734 }
5735 }
5736
ParseTree(QTreeWidgetItem * item)5737 void Texmaker::ParseTree(QTreeWidgetItem *item)
5738 {
5739
5740 if (item->childCount()>0)
5741 {
5742 for (int i = 0; i < item->childCount(); i++)
5743 {
5744 ItemToRange(item->child(i));
5745 }
5746 }
5747
5748 if (item->childCount()>0)
5749 {
5750 for (int i = 0; i < item->childCount(); i++)
5751 {
5752 ParseTree(item->child(i));
5753 }
5754 }
5755
5756 }
5757
LevelItem(const QTreeWidgetItem * item)5758 int Texmaker::LevelItem(const QTreeWidgetItem *item)
5759 {
5760 int level=0;
5761 const QList<StructItem>& structure = currentEditorView()->editor->getStructItems();
5762 if ((item) && (structure.count()>0))
5763 {
5764 int index = item->text(1).toInt();
5765 if (index<structure.count())
5766 {
5767 if ((structure.at(index).type<=3) || (structure.at(index).type==9) ) level=0;
5768 else level=structure.at(index).type-3;
5769 }
5770 }
5771 return level;
5772
5773 /*if ((item) && (!structlist.isEmpty()))
5774 {
5775 QStringList::ConstIterator it1 = structitem.begin();
5776 QList<int>::ConstIterator it3 = structlevel.begin();
5777 for ( ; it1 !=structitem.end(); ++it1 )
5778 {
5779 if (*it1==item->text(0)) break;
5780 ++it3;
5781 }
5782 level=*it3;
5783 }
5784 return level;*/
5785 }
5786
LineItem(const QTreeWidgetItem * item)5787 int Texmaker::LineItem(const QTreeWidgetItem *item)
5788 {
5789 int line=-1;
5790 const QList<StructItem>& structure = currentEditorView()->editor->getStructItems();
5791 if ((item) && (structure.count()>0))
5792 {
5793 int index = item->text(1).toInt();
5794 if (index<structure.count())
5795 {
5796 line=structure.at(index).cursor.block().blockNumber();//line=structure.at(index).line;
5797 }
5798 }
5799 return line;
5800
5801 /*if ((item) && (!structlist.isEmpty()))
5802 {
5803 QStringList::ConstIterator it1 = structitem.begin();
5804 QStringList::ConstIterator it2 = structlist.begin();
5805 for ( ; it1 !=structitem.end(); ++it1 )
5806 {
5807 if (*it1==item->text(0)) break;
5808 ++it2;
5809 }
5810 QString s=*it2;
5811 bool ok;
5812 int l=s.toInt(&ok,10);
5813 if (ok) line=l;
5814 }
5815 return line;*/
5816 }
5817
ItemToRange(QTreeWidgetItem * item)5818 void Texmaker::ItemToRange(QTreeWidgetItem *item)
5819 {
5820 if (!item) return;
5821 QTreeWidgetItem *parentitem, *theitem;
5822 theitem=item;
5823 int start=-1;
5824 int end=-1;
5825 int level=LevelItem(item);
5826 int index;
5827 if (level>=1)
5828 {
5829 start=LineItem(theitem);
5830 do
5831 {
5832 parentitem=theitem->parent();
5833 if (parentitem)
5834 {
5835 index=parentitem->indexOfChild(theitem);
5836 theitem=parentitem;
5837 }
5838 else index=-1;
5839 }
5840 while ((index>=0)&&(index>=parentitem->childCount()-1)&&(LevelItem(parentitem)>=1));
5841 if (index>=0 && index<parentitem->childCount()-1) end=LineItem(parentitem->child(index+1));
5842 else
5843 {
5844 end=currentEditorView()->editor->searchLine("\\end{document}");
5845 if (end<0) end=currentEditorView()->editor->numoflines();
5846 }
5847 if (start<end-1) {currentEditorView()->editor->foldableLines.insert(start,end-1);}
5848 }
5849 }
5850
ClickedOnStructure(QTreeWidgetItem * item,int col)5851 void Texmaker::ClickedOnStructure(QTreeWidgetItem *item,int col)
5852 {
5853 if ( !currentEditorView() ) return;
5854 QString finame;
5855 if (singlemode) {finame=getName();}
5856 else {finame=MasterName;}
5857 QString name,flname,basename;
5858 bool hasname=true;
5859 if ((singlemode && !currentEditorView()) || finame.startsWith("untitled") || finame=="")
5860 {
5861 hasname=false;
5862 }
5863 else
5864 {
5865 QFileInfo fi(finame);
5866 name=fi.absoluteFilePath();
5867 flname=fi.fileName();
5868 basename=name.left(name.length()-flname.length());
5869 }
5870 if (item)
5871 {
5872 int index = item->text(1).toInt();
5873 const QList<StructItem>& structure = currentEditorView()->editor->getStructItems();
5874 if (index<structure.count())
5875 {
5876 int type=structure.at(index).type;
5877 if (hasname && (type==2) || (type==3))
5878 {
5879 QString fname=structure.at(index).item;
5880 loadIncludeFiles(fname,".tex");
5881 }
5882 else if (hasname && (type==9))
5883 {
5884 QString fname=structure.at(index).item;
5885 loadIncludeFiles(fname,".bib");
5886 }
5887 else
5888 {
5889 currentEditorView()->editor->gotoLine(structure.at(index).cursor.block().blockNumber());
5890 if (!hasname) return;
5891 QFileInfo fic(finame);
5892 if (!fic.exists()) return;
5893 QString basename=fic.completeBaseName();
5894 if (embedinternalpdf && builtinpdfview)
5895 {
5896 if (pdfviewerWidget)
5897 {
5898 if (pdfviewerWidget->pdf_file!=fic.absolutePath()+"/"+basename+".pdf") pdfviewerWidget->openFile(fic.absolutePath()+"/"+basename+".pdf",viewpdf_command,ghostscript_command);
5899 StackedViewers->setCurrentWidget(pdfviewerWidget);
5900 pdfviewerWidget->show();
5901 if ( (pdflatex_command.contains("synctex=1")) || (latex_command.contains("synctex=1")) || (xelatex_command.contains("synctex=1"))) pdfviewerWidget->jumpToPdfFromSource(getName(),structure.at(index).cursor.block().blockNumber()+1,1);
5902 }
5903 }
5904 }
5905 }
5906 }
5907
5908 }
5909
5910 //////////TAGS////////////////
InsertTag(QString Entity,int dx,int dy)5911 void Texmaker::InsertTag(QString Entity, int dx, int dy)
5912 {
5913 if ( !currentEditorView() ) return;
5914 OutputTextEdit->clear();
5915 QTextCursor cur=currentEditorView()->editor->textCursor();
5916 int pos=cur.position();
5917 if (!Entity.startsWith("\\og")) Entity.replace("{}","{"+QString(0x2022)+"}");
5918 Entity.replace("[]","["+QString(0x2022)+"]");
5919 Entity.replace("\n\n","\n"+QString(0x2022)+"\n");
5920 currentEditorView()->editor->insertWithMemoryIndent(Entity);
5921 cur.setPosition(pos,QTextCursor::MoveAnchor);
5922 if (Entity.contains(QString(0x2022)))
5923 {
5924 currentEditorView()->editor->setTextCursor(cur);
5925 currentEditorView()->editor->search(QString(0x2022) ,true,false,true,true,false);
5926 OutputTextEdit->insertLine("Use the Tab key to reach the next "+QString(0x2022)+" field");
5927 }
5928 else
5929 {
5930 if (dy>0) cur.movePosition(QTextCursor::Down,QTextCursor::MoveAnchor,dy);
5931 if (dx>0) cur.movePosition(QTextCursor::NextCharacter,QTextCursor::MoveAnchor,dx);
5932 currentEditorView()->editor->setTextCursor(cur);
5933 }
5934 currentEditorView()->editor->setFocus();
5935 OutputTableWidget->hide();
5936 OutputTextEdit->setMaximumHeight(splitter2->sizes().at(1));
5937 separatorline->hide();
5938 logpresent=false;
5939 }
5940
InsertSymbol(QTableWidgetItem * item)5941 void Texmaker::InsertSymbol(QTableWidgetItem *item)
5942 {
5943 QString code_symbol;
5944 QRegExp rxnumber(";([0-9]+)");
5945 int number=-1;
5946 int dx;
5947 if (item)
5948 {
5949 if ( rxnumber.indexIn(item->text()) != -1) number=rxnumber.cap(1).toInt();
5950 if ((number>-1) && (number<412)) symbolScore[number]=symbolScore[number]+1;
5951 code_symbol=item->text().remove(rxnumber);
5952 dx=code_symbol.indexOf("{}",0);
5953 if (dx>-1) InsertTag(code_symbol,dx+1,0);
5954 else InsertTag(code_symbol,code_symbol.length(),0);
5955 SetMostUsedSymbols();
5956 }
5957 }
5958
InsertXmlTag(QListWidgetItem * item)5959 void Texmaker::InsertXmlTag(QListWidgetItem *item)
5960 {
5961 if ( !currentEditorView() ) return;
5962 QString txt, code, role;
5963 QStringList tagList;
5964 int dx,dy;
5965 if (item && !item->font().bold())
5966 {
5967 txt=item->text();
5968 txt.remove(QRegExp("\\[(.*)\\]"));
5969 txt.replace(QRegExp("([^\\\\])\\\\n"), "\\1\n");
5970 txt.replace(QRegExp("([^\\\\])\\\\n"), "\\1\n");
5971 role=item->data(Qt::UserRole).toString();
5972 tagList= role.split("#");
5973 code=tagList.at(0);
5974 code.remove(QRegExp("\\[(.*)\\]"));
5975 code.replace(QRegExp("([^\\\\])\\\\n"), "\\1\n");
5976 code.replace(QRegExp("([^\\\\])\\\\n"), "\\1\n");
5977 dx=tagList.at(1).toInt();
5978 dy=tagList.at(2).toInt();
5979 if ((dx==0) && (dy==0))
5980 {
5981 if (!currentEditorView()->editor->textCursor().hasSelection()) dx=code.length();
5982 else dx=code.length()-currentEditorView()->editor->textCursor().selectedText().length();
5983 }
5984 InsertTag(code,dx,dy);
5985 }
5986 }
5987
InsertUserElement(QListWidgetItem * item)5988 void Texmaker::InsertUserElement(QListWidgetItem *item)
5989 {
5990 if ( !currentEditorView() ) return;
5991 QString txt, code, role;
5992 QStringList tagList;
5993 int dx;
5994 if (item)
5995 {
5996 txt=item->text();
5997 role=item->data(Qt::UserRole).toString();
5998 tagList= role.split("#");
5999 code=tagList.at(0);
6000 if (code.left(1)=="%")
6001 {
6002 QString t=code;
6003 t=t.remove(0,1);
6004 QString s="\\begin{"+t+"}\n"+QString(0x2022)+"\n\\end{"+t+"}\n";
6005 InsertUserTag(s);
6006 }
6007 else
6008 {
6009 InsertUserTag(code);
6010 }
6011 }
6012 }
6013
InsertFromAction()6014 void Texmaker::InsertFromAction()
6015 {
6016 bool ok;
6017 QString actData;
6018 QStringList tagList;
6019 QAction *action = qobject_cast<QAction *>(sender());
6020 if ( !currentEditorView() ) return;
6021 if (action)
6022 {
6023 actData=action->data().toString();
6024 tagList= actData.split("/");
6025 InsertTag(tagList.at(0),tagList.at(1).toInt(&ok, 10),tagList.at(2).toInt(&ok, 10));
6026 OutputTextEdit->insertLine(tagList.at(3));
6027 }
6028 }
6029
InsertWithSelectionFromAction()6030 void Texmaker::InsertWithSelectionFromAction()
6031 {
6032 bool ok;
6033 QString actData;
6034 QStringList tagList;
6035 QAction *action = qobject_cast<QAction *>(sender());
6036 if ( !currentEditorView() ) return;
6037 if (action)
6038 {
6039 actData=action->data().toString();
6040 tagList= actData.split("/");
6041 if (!currentEditorView()->editor->textCursor().hasSelection())
6042 {
6043 OutputTextEdit->insertLine("You can select a text before using this environment.");
6044 InsertTag(tagList.at(0)+tagList.at(1),tagList.at(2).toInt(&ok, 10),tagList.at(3).toInt(&ok, 10));
6045 }
6046 else
6047 {
6048 currentEditorView()->editor->cut();
6049 InsertTag(tagList.at(0)+tagList.at(1),tagList.at(2).toInt(&ok, 10),tagList.at(3).toInt(&ok, 10));
6050 currentEditorView()->editor->paste();
6051 // InsertTag(tagList.at(1),0,0);
6052 }
6053 }
6054 }
6055
InsertWithSelectionFromString(const QString & text)6056 void Texmaker::InsertWithSelectionFromString(const QString& text)
6057 {
6058 bool ok;
6059 QStringList tagList;
6060 if ( !currentEditorView() ) return;
6061 tagList= text.split("/");
6062 if (!currentEditorView()->editor->textCursor().hasSelection())
6063 {
6064 InsertTag(tagList.at(0)+QString(0x2022)+tagList.at(1),tagList.at(2).toInt(&ok, 10),tagList.at(3).toInt(&ok, 10));
6065 }
6066 else
6067 {
6068 currentEditorView()->editor->cut();
6069 InsertTag(tagList.at(0)+QString(0x2022)+tagList.at(1),tagList.at(2).toInt(&ok, 10),tagList.at(3).toInt(&ok, 10));
6070 currentEditorView()->editor->paste();
6071 // InsertTag(tagList.at(1),0,0);
6072 }
6073 }
6074
InsertFromString(const QString & text)6075 void Texmaker::InsertFromString(const QString& text)
6076 {
6077 bool ok;
6078 QStringList tagList;
6079 if ( !currentEditorView() ) return;
6080 tagList= text.split("/");
6081 InsertTag(tagList.at(0),tagList.at(1).toInt(&ok, 10),tagList.at(2).toInt(&ok, 10));
6082 }
6083
InsertBib()6084 void Texmaker::InsertBib()
6085 {
6086 if ( !currentEditorView() ) return;
6087 //currentEditorView()->editor->viewport()->setFocus();
6088 QString tag;
6089 QFileInfo fi(getName());
6090 tag=QString("\\bibliography{");
6091 tag +=fi.completeBaseName();
6092 tag +=QString("}\n");
6093 InsertTag(tag,0,1);
6094 OutputTextEdit->clear();
6095 OutputTableWidget->hide();
6096 OutputTextEdit->setMaximumHeight(splitter2->sizes().at(1));
6097 separatorline->hide();
6098 OutputTextEdit->insertLine("The argument to \\bibliography refers to the bib file (without extension)");
6099 OutputTextEdit->insertLine("which should contain your database in BibTeX format.");
6100 OutputTextEdit->insertLine("Texmaker inserts automatically the base name of the TeX file");
6101 }
6102
InsertBibLatex()6103 void Texmaker::InsertBibLatex()
6104 {
6105 if ( !currentEditorView() ) return;
6106 //currentEditorView()->editor->viewport()->setFocus();
6107 QString tag;
6108 QFileInfo fi(getName());
6109 tag=QString("\\addbibresource{");
6110 tag +=fi.completeBaseName();
6111 tag +=QString("}\n");
6112 InsertTag(tag,0,1);
6113 OutputTextEdit->clear();
6114 OutputTableWidget->hide();
6115 OutputTextEdit->setMaximumHeight(splitter2->sizes().at(1));
6116 separatorline->hide();
6117 OutputTextEdit->insertLine("The argument to \\bibliography refers to the bib file (without extension)");
6118 OutputTextEdit->insertLine("which should contain your database in BibTeX format.");
6119 OutputTextEdit->insertLine("Texmaker inserts automatically the base name of the TeX file");
6120 }
6121
InsertStruct()6122 void Texmaker::InsertStruct()
6123 {
6124 QString actData, tag;
6125 if ( !currentEditorView() ) return;
6126 //currentEditorView()->editor->viewport()->setFocus();
6127 QAction *action = qobject_cast<QAction *>(sender());
6128 if (action)
6129 {
6130 actData=action->data().toString();
6131 StructDialog *stDlg = new StructDialog(this,actData);
6132 if ( stDlg->exec() )
6133 {
6134 if (stDlg->ui.checkBox->isChecked())
6135 {tag=actData+"{";}
6136 else
6137 {tag=actData+"*{";}
6138 tag +=stDlg->ui.TitlelineEdit->text();
6139 tag +=QString("}\n");
6140 InsertTag(tag,0,1);
6141 //UpdateStructure();
6142 }
6143 }
6144 }
6145
InsertStructFromString(const QString & text)6146 void Texmaker::InsertStructFromString(const QString& text)
6147 {
6148 QString tag;
6149 if ( !currentEditorView() ) return;
6150 //currentEditorView()->editor->viewport()->setFocus();
6151 StructDialog *stDlg = new StructDialog(this,text);
6152 if ( stDlg->exec() )
6153 {
6154 if (stDlg->ui.checkBox->isChecked())
6155 {tag=text+"{";}
6156 else
6157 {tag=text+"*{";}
6158 tag +=stDlg->ui.TitlelineEdit->text();
6159 tag +=QString("}\n");
6160 InsertTag(tag,0,1);
6161 //UpdateStructure();
6162 }
6163 }
6164
InsertImage()6165 void Texmaker::InsertImage()
6166 {
6167 if ( !currentEditorView() ) return;
6168 QString tag;
6169 QString currentDir=QDir::homePath();
6170 QString finame;
6171 if (singlemode) {finame=getName();}
6172 else {finame=MasterName;}
6173 QFileInfo fi(finame);
6174 if (!finame.startsWith("untitled")) currentDir=fi.absolutePath();
6175 QDir rootdir=fi.dir();
6176 GraphicFileChooser *sfDlg = new GraphicFileChooser(this,tr("Select an image File"));
6177 sfDlg->setFilter("Graphic files (*.eps *.pdf *.png *.jpeg *.jpg *.tiff);;All files (*.*)");
6178 sfDlg->setDir(currentDir);
6179 if (sfDlg->exec() )
6180 {
6181 QString fn=sfDlg->fileName();
6182 QFileInfo fi(rootdir.relativeFilePath(fn));
6183 if (!sfDlg->ui.moreButton->isChecked()) InsertTag("\\includegraphics[scale=1]{"+fi.filePath()+"} ",26,0);
6184 else
6185 {
6186 tag = "\\begin{figure}["+sfDlg->ui.lineEditPlacement->text()+"]\n";
6187 if(sfDlg->ui.comboBoxCaption->currentIndex()==0) tag+="\\caption{"+sfDlg->ui.lineEditCaption->text()+"}\n";
6188 if (sfDlg->ui.checkBoxCentering->isChecked()) tag+="\\centering\n";
6189 tag+="\\includegraphics[scale=1]{"+fi.filePath()+"}\n";
6190 if(sfDlg->ui.comboBoxCaption->currentIndex()==1) tag+="\\caption{"+sfDlg->ui.lineEditCaption->text()+"}\n";
6191 tag+="\\end{figure}\n";
6192 InsertTag(tag,0,4);
6193 }
6194 }
6195 }
6196
InsertInclude()6197 void Texmaker::InsertInclude()
6198 {
6199 if ( !currentEditorView() ) return;
6200 QString currentDir=QDir::homePath();
6201 QString finame;
6202 if (singlemode) {finame=getName();}
6203 else {finame=MasterName;}
6204 QFileInfo fi(finame);
6205 if (!finame.startsWith("untitled")) currentDir=fi.absolutePath();
6206 QDir rootdir=fi.dir();
6207 FileChooser *sfDlg = new FileChooser(this,tr("Select a File"));
6208 sfDlg->setFilter("TeX files (*.tex);;All files (*.*)");
6209 sfDlg->setDir(currentDir);
6210 if (sfDlg->exec() )
6211 {
6212 QString fn=sfDlg->fileName();
6213 QFileInfo fi(rootdir.relativeFilePath(fn));
6214 QString suff=fi.suffix();
6215 QString name=fi.filePath();
6216 name=name.left(name.length()-suff.length()-1);
6217 InsertTag("\\include{"+name+"}",9,0);
6218 }
6219 //UpdateStructure();
6220 }
6221
InsertInput()6222 void Texmaker::InsertInput()
6223 {
6224 if ( !currentEditorView() ) return;
6225 QString currentDir=QDir::homePath();
6226 QString finame;
6227 if (singlemode) {finame=getName();}
6228 else {finame=MasterName;}
6229 QFileInfo fi(finame);
6230 if (!finame.startsWith("untitled")) currentDir=fi.absolutePath();
6231 QDir rootdir=fi.dir();
6232 FileChooser *sfDlg = new FileChooser(this,tr("Select a File"));
6233 sfDlg->setFilter("TeX files (*.tex);;All files (*.*)");
6234 sfDlg->setDir(currentDir);
6235 if (sfDlg->exec() )
6236 {
6237 QString fn=sfDlg->fileName();
6238 QFileInfo fi(rootdir.relativeFilePath(fn));
6239 QString suff=fi.suffix();
6240 QString name=fi.filePath();
6241 name=name.left(name.length()-suff.length()-1);
6242 InsertTag("\\input{"+name+"}",7,0);
6243 }
6244 //UpdateStructure();
6245 }
6246
QuickTabular()6247 void Texmaker::QuickTabular()
6248 {
6249 if ( !currentEditorView() ) return;
6250 QStringList borderlist, alignlist;
6251 borderlist<< QString("|") << QString("||") << QString("") << QString("@{}");
6252 alignlist << QString("c") << QString("l") << QString("r") << QString("p{}") << QString(">{\\centering\\arraybackslash}p{}") << QString(">{\\raggedleft\\arraybackslash}p{}");
6253 QString al="";
6254 QString vs="";
6255 QString el="";
6256 QString tag;
6257 TabDialog *quickDlg = new TabDialog(this,"Tabular");
6258 QTableWidgetItem *item=new QTableWidgetItem();
6259 if ( quickDlg->exec() )
6260 {
6261 int y = quickDlg->ui.spinBoxRows->value();
6262 int x = quickDlg->ui.spinBoxColumns->value();
6263 tag = QString("\\begin{tabular}{");
6264 for ( int j=0;j<x;j++)
6265 {
6266 tag+=borderlist.at(quickDlg->colDataList.at(j).leftborder);
6267 tag+=alignlist.at(quickDlg->colDataList.at(j).alignment);
6268 }
6269 tag+=borderlist.at(quickDlg->ui.comboBoxEndBorder->currentIndex());
6270 tag +=QString("}\n");
6271 for ( int i=0;i<y;i++)
6272 {
6273 if (quickDlg->liDataList.at(i).topborder) tag+=QString("\\hline \n");
6274 if (quickDlg->ui.checkBoxMargin->isChecked()) tag+="\\rule[-1ex]{0pt}{2.5ex} ";
6275 if (quickDlg->liDataList.at(i).merge && (quickDlg->liDataList.at(i).mergeto>quickDlg->liDataList.at(i).mergefrom))
6276 {
6277 el="";
6278 for ( int j=0;j<x;j++)
6279 {
6280 item =quickDlg->ui.tableWidget->item(i,j);
6281
6282 if (j==quickDlg->liDataList.at(i).mergefrom-1)
6283 {
6284 if (item) el+=item->text();
6285 tag+=QString("\\multicolumn{");
6286 tag+=QString::number(quickDlg->liDataList.at(i).mergeto-quickDlg->liDataList.at(i).mergefrom+1);
6287 tag+=QString("}{");
6288 if ((j==0) && (quickDlg->colDataList.at(j).leftborder<2)) tag+=borderlist.at(quickDlg->colDataList.at(j).leftborder);
6289 if (quickDlg->colDataList.at(j).alignment<3) tag+=alignlist.at(quickDlg->colDataList.at(j).alignment);
6290 else tag+=QString("c");
6291 if (quickDlg->liDataList.at(i).mergeto==x) tag+=borderlist.at(quickDlg->ui.comboBoxEndBorder->currentIndex());
6292 else tag+=borderlist.at(quickDlg->colDataList.at(quickDlg->liDataList.at(i).mergeto).leftborder);
6293 tag+=QString("}{");
6294 }
6295 else if (j==quickDlg->liDataList.at(i).mergeto-1)
6296 {
6297 if (item) el+=item->text();
6298 if (el.isEmpty()) el=QString(0x2022);
6299 tag+=el+QString("}");
6300 if (j<x-1) tag+=" & ";
6301 else tag+=QString(" \\\\ \n");
6302 }
6303 else if ((j>quickDlg->liDataList.at(i).mergefrom-1) && (j<quickDlg->liDataList.at(i).mergeto-1))
6304 {
6305 if (item) el+=item->text();
6306 }
6307 else
6308 {
6309 if (item)
6310 {
6311 if (item->text().isEmpty()) tag +=QString(0x2022);
6312 else tag +=item->text();
6313 }
6314 else tag +=QString(0x2022);
6315 if (j<x-1) tag+=" & ";
6316 else tag+=QString(" \\\\ \n");
6317 }
6318
6319 }
6320 }
6321 else
6322 {
6323 for ( int j=0;j<x-1;j++)
6324 {
6325 item =quickDlg->ui.tableWidget->item(i,j);
6326 if (item)
6327 {
6328 if (item->text().isEmpty()) tag +=QString(0x2022)+QString(" & ");
6329 else tag +=item->text()+ QString(" & ");
6330 }
6331 else tag +=QString(0x2022)+QString(" & ");
6332 }
6333 item =quickDlg->ui.tableWidget->item(i,x-1);
6334 if (item)
6335 {
6336 if (item->text().isEmpty()) tag +=QString(0x2022)+QString(" \\\\ \n");
6337 else tag +=item->text()+ QString(" \\\\ \n");
6338 }
6339 else tag +=QString(0x2022)+QString(" \\\\ \n");
6340 }
6341 }
6342 if (quickDlg->ui.checkBoxBorderBottom->isChecked()) tag +=QString("\\hline \n\\end{tabular} ");
6343 else tag +=QString("\\end{tabular} ");
6344 if (tag.contains("arraybackslash")) tag="% \\usepackage{array} is required\n"+tag;
6345 InsertTag(tag,0,0);
6346 }
6347
6348 }
6349
QuickArray()6350 void Texmaker::QuickArray()
6351 {
6352 if ( !currentEditorView() ) return;
6353 QString al;
6354 ArrayDialog *arrayDlg = new ArrayDialog(this,"Array");
6355 QTableWidgetItem *item=new QTableWidgetItem();
6356 if ( arrayDlg->exec() )
6357 {
6358 int y = arrayDlg->ui.spinBoxRows->value();
6359 int x = arrayDlg->ui.spinBoxColumns->value();
6360 QString env=arrayDlg->ui.comboEnvironment->currentText();
6361 QString tag = QString("\\begin{")+env+"}";
6362 if (env=="array")
6363 {
6364 tag+="{";
6365 if ((arrayDlg->ui.comboAlignment->currentIndex())==0) al=QString("c");
6366 if ((arrayDlg->ui.comboAlignment->currentIndex())==1) al=QString("l");
6367 if ((arrayDlg->ui.comboAlignment->currentIndex())==2) al=QString("r");
6368 for ( int j=0;j<x;j++) {tag +=al;} tag+="}";
6369 }
6370 tag +=QString("\n");
6371 for ( int i=0;i<y-1;i++)
6372 {
6373 for ( int j=0;j<x-1;j++)
6374 {
6375 item =arrayDlg->ui.tableWidget->item(i,j);
6376 if (item) tag +=item->text()+ QString(" & ");
6377 else tag +=QString(0x2022)+QString(" & ");
6378 }
6379 item =arrayDlg->ui.tableWidget->item(i,x-1);
6380 if (item) tag +=item->text()+ QString(" \\\\ \n");
6381 else tag +=QString(0x2022)+QString(" \\\\ \n");
6382 }
6383 for ( int j=0;j<x-1;j++)
6384 {
6385 item =arrayDlg->ui.tableWidget->item(y-1,j);
6386 if (item) tag +=item->text()+ QString(" & ");
6387 else tag +=QString(0x2022)+QString(" & ");
6388 }
6389 item =arrayDlg->ui.tableWidget->item(y-1,x-1);
6390 if (item) tag +=item->text()+ QString("\n\\end{")+env+"} ";
6391 else tag +=QString(0x2022)+QString("\n\\end{")+env+"} ";
6392 InsertTag(tag,0,0);
6393 }
6394 }
6395
QuickTabbing()6396 void Texmaker::QuickTabbing()
6397 {
6398 if ( !currentEditorView() ) return;
6399 TabbingDialog *tabDlg = new TabbingDialog(this,"Tabbing");
6400 if ( tabDlg->exec() )
6401 {
6402 int x = tabDlg->ui.spinBoxColumns->value();
6403 int y = tabDlg->ui.spinBoxRows->value();
6404 QString s=tabDlg->ui.lineEdit->text();
6405 QString tag = QString("\\begin{tabbing}\n");
6406 for ( int j=1;j<x;j++) {tag +="\\hspace{"+s+"}\\=";}
6407 tag+="\\kill\n";
6408 for ( int i=0;i<y-1;i++)
6409 {
6410 for ( int j=1;j<x;j++) {tag +=" "+QString(0x2022)+" \\> ";}
6411 tag+=QString(0x2022)+" \\\\ \n";
6412 }
6413 for ( int j=1;j<x;j++) {tag +=" "+QString(0x2022)+" \\> ";}
6414 tag +=QString(0x2022)+QString("\n\\end{tabbing} ");
6415 InsertTag(tag,0,2);
6416 }
6417 }
6418
QuickLetter()6419 void Texmaker::QuickLetter()
6420 {
6421 if ( !currentEditorView() ) return;
6422 QString tag=QString("\\documentclass[");
6423 LetterDialog *ltDlg = new LetterDialog(this,"Letter");
6424 int f=ltDlg->ui.comboBoxEncoding->findText(document_encoding,Qt::MatchExactly | Qt::MatchCaseSensitive);
6425 ltDlg->ui.comboBoxEncoding->setCurrentIndex(f);
6426 if ( ltDlg->exec() )
6427 {
6428 tag+=ltDlg->ui.comboBoxPt->currentText()+QString(",");
6429 tag+=ltDlg->ui.comboBoxPaper->currentText()+QString("]{letter}");
6430 tag+=QString("\n");
6431 if (ltDlg->ui.comboBoxEncoding->currentText()!="NONE") tag+=QString("\\usepackage[")+ltDlg->ui.comboBoxEncoding->currentText()+QString("]{inputenc}");
6432 if (ltDlg->ui.comboBoxEncoding->currentText().startsWith("utf8x")) tag+=QString(" \\usepackage{ucs}");
6433 tag+=QString("\n");
6434 if (ltDlg->ui.checkBox->isChecked()) tag+=QString("\\usepackage{amsmath}\n\\usepackage{amsfonts}\n\\usepackage{amssymb}\n");
6435 tag+="\\address{your name and address} \n";
6436 tag+="\\signature{your signature} \n";
6437 tag+="\\begin{document} \n";
6438 tag+="\\begin{letter}{name and address of the recipient} \n";
6439 tag+="\\opening{saying hello} \n \n";
6440 tag+="write your letter here \n \n";
6441 tag+="\\closing{saying goodbye} \n";
6442 tag+="%\\cc{Cclist} \n";
6443 tag+="%\\ps{adding a postscript} \n";
6444 tag+="%\\encl{list of enclosed material} \n";
6445 tag+="\\end{letter} \n";
6446 tag+="\\end{document}";
6447 if (ltDlg->ui.checkBox->isChecked()) {InsertTag(tag,9,5);}
6448 else {InsertTag(tag,9,2);}
6449 }
6450 }
6451
QuickDocument()6452 void Texmaker::QuickDocument()
6453 {
6454 QString opt="";
6455 QString optbabel="";
6456 int li=3;
6457 int f;
6458 QString fontenc="";
6459 if ( !currentEditorView() ) fileNew();
6460 QString tag=QString("\\documentclass[");
6461 QuickDocumentDialog *startDlg = new QuickDocumentDialog(this,"Quick Start");
6462 startDlg->otherClassList=userClassList;
6463 startDlg->otherPaperList=userPaperList;
6464 startDlg->otherEncodingList=userEncodingList;
6465 startDlg->otherOptionsList=userOptionsList;
6466 startDlg->otherBabelList=userBabelList;
6467 startDlg->Init();
6468 f=startDlg->ui.comboBoxClass->findText(document_class,Qt::MatchExactly | Qt::MatchCaseSensitive);
6469 startDlg->ui.comboBoxClass->setCurrentIndex(f);
6470 f=startDlg->ui.comboBoxSize->findText(typeface_size,Qt::MatchExactly | Qt::MatchCaseSensitive);
6471 startDlg->ui.comboBoxSize->setCurrentIndex(f);
6472 f=startDlg->ui.comboBoxPaper->findText(paper_size,Qt::MatchExactly | Qt::MatchCaseSensitive);
6473 startDlg->ui.comboBoxPaper->setCurrentIndex(f);
6474 f=startDlg->ui.comboBoxEncoding->findText(document_encoding,Qt::MatchExactly | Qt::MatchCaseSensitive);
6475 startDlg->ui.comboBoxEncoding->setCurrentIndex(f);
6476 QList<QListWidgetItem *> babItems=startDlg->ui.listWidgetBabel->findItems(babel_default,Qt::MatchExactly | Qt::MatchCaseSensitive);
6477 if (babItems.size()>0) startDlg->ui.listWidgetBabel->setCurrentItem(babItems.at(0));
6478 startDlg->ui.checkBoxAMS->setChecked(ams_packages);
6479 startDlg->ui.checkBoxIDX->setChecked(makeidx_package);
6480 startDlg->ui.checkBoxBabel->setChecked(babel_package);
6481 startDlg->ui.listWidgetBabel->setEnabled(babel_package);
6482 startDlg->ui.pushButtonBabel->setEnabled(babel_package);
6483 startDlg->ui.checkBoxGeometry->setChecked(geometry_package);
6484 startDlg->ui.lineEditGeometry->setEnabled(geometry_package);
6485 startDlg->ui.checkBoxGraphicx->setChecked(graphicx_package);
6486 startDlg->ui.checkBoxLmodern->setChecked(lmodern_package);
6487 startDlg->ui.checkBoxKpfonts->setChecked(kpfonts_package);
6488 startDlg->ui.checkBoxFourier->setChecked(fourier_package);
6489 startDlg->ui.lineEditAuthor->setText(author);
6490 startDlg->ui.lineEditGeometry->setText(geometry_options);
6491 if ( startDlg->exec() )
6492 {
6493 tag+=startDlg->ui.comboBoxSize->currentText()+QString(",");
6494 tag+=startDlg->ui.comboBoxPaper->currentText();
6495 QList<QListWidgetItem *> selectedItems=startDlg->ui.listWidgetOptions->selectedItems();
6496 for (int i = 0; i < selectedItems.size(); ++i)
6497 {
6498 if ( selectedItems.at(i)) opt+=QString(",")+selectedItems.at(i)->text();
6499 }
6500 tag+=opt+QString("]{");
6501 tag+=startDlg->ui.comboBoxClass->currentText()+QString("}");
6502 tag+=QString("\n");
6503 if (startDlg->ui.comboBoxEncoding->currentText()!="NONE") tag+=QString("\\usepackage[")+startDlg->ui.comboBoxEncoding->currentText()+QString("]{inputenc}");
6504 tag+=QString("\n");
6505 if (startDlg->ui.comboBoxEncoding->currentText().startsWith("utf8x"))
6506 {
6507 tag+=QString("\\usepackage{ucs}\n");
6508 li=li+1;
6509 }
6510 if (startDlg->ui.checkBoxBabel->isChecked())
6511 {
6512 QList<QListWidgetItem *> babelItems=startDlg->ui.listWidgetBabel->selectedItems();
6513 for (int i = 0; i < babelItems.size(); ++i)
6514 {
6515 if ( babelItems.at(i))
6516 {
6517 if ((babelItems.at(i)->text()=="arabic") && fontenc.isEmpty()) fontenc="LAE,LFE";
6518 else if ((babelItems.at(i)->text()=="russian") && fontenc.isEmpty()) fontenc="OT1";
6519 else if ((babelItems.at(i)->text()=="slovak") && fontenc.isEmpty()) fontenc="IL2";
6520 else if ((babelItems.at(i)->text()=="francais") && fontenc.isEmpty()) fontenc="T1";
6521 else if ((babelItems.at(i)->text()=="french") && fontenc.isEmpty()) fontenc="T1";
6522 else if ((babelItems.at(i)->text()=="frenchb") && fontenc.isEmpty()) fontenc="T1";
6523 else if ((babelItems.at(i)->text()=="german") && fontenc.isEmpty()) fontenc="T1";
6524 else if ((babelItems.at(i)->text()=="portuguese") && fontenc.isEmpty()) fontenc="T1";
6525 else if ((babelItems.at(i)->text()=="icelandic") && fontenc.isEmpty()) fontenc="T1";
6526 else if ((babelItems.at(i)->text()=="czech") && fontenc.isEmpty()) fontenc="T1";
6527 else if ((babelItems.at(i)->text()=="magyar") && fontenc.isEmpty()) fontenc="T1";
6528 else if ((babelItems.at(i)->text()=="finnish") && fontenc.isEmpty()) fontenc="T1";
6529 if (i==0)
6530 {
6531 optbabel+=babelItems.at(i)->text();
6532 babel_default=babelItems.at(i)->text();
6533 }
6534 else optbabel+=QString(",")+babelItems.at(i)->text();
6535 }
6536 }
6537 tag+=QString("\\usepackage["+optbabel+"]{babel}\n");
6538 li=li+1;
6539 if (!fontenc.isEmpty())
6540 {
6541 tag+=QString("\\usepackage["+fontenc+"]{fontenc}\n");
6542 li=li+1;
6543 }
6544 }
6545 if (startDlg->ui.checkBoxAMS->isChecked())
6546 {
6547 tag+=QString("\\usepackage{amsmath}\n\\usepackage{amsfonts}\n\\usepackage{amssymb}\n");
6548 li=li+3;
6549 }
6550 if (startDlg->ui.checkBoxIDX->isChecked())
6551 {
6552 tag+=QString("\\usepackage{makeidx}\n");
6553 li=li+1;
6554 }
6555 if (startDlg->ui.checkBoxGraphicx->isChecked())
6556 {
6557 tag+=QString("\\usepackage{graphicx}\n");
6558 li=li+1;
6559 }
6560 if (startDlg->ui.checkBoxLmodern->isChecked())
6561 {
6562 tag+=QString("\\usepackage{lmodern}\n");
6563 li=li+1;
6564 }
6565 if (startDlg->ui.checkBoxKpfonts->isChecked())
6566 {
6567 tag+=QString("\\usepackage{kpfonts}\n");
6568 li=li+1;
6569 }
6570 if (startDlg->ui.checkBoxFourier->isChecked())
6571 {
6572 tag+=QString("\\usepackage{fourier}\n");
6573 li=li+1;
6574 }
6575 if (startDlg->ui.checkBoxGeometry->isChecked())
6576 {
6577 tag+=QString("\\usepackage["+startDlg->ui.lineEditGeometry->text()+"]{geometry}\n");
6578 li=li+1;
6579 }
6580 if (startDlg->ui.lineEditAuthor->text()!="")
6581 {
6582 tag+="\\author{"+startDlg->ui.lineEditAuthor->text()+"}\n";
6583 li=li+1;
6584 }
6585 if (startDlg->ui.lineEditTitle->text()!="")
6586 {
6587 tag+="\\title{"+startDlg->ui.lineEditTitle->text()+"}\n";
6588 li=li+1;
6589 }
6590 tag+=QString("\\begin{document}\n\n\\end{document}");
6591 InsertTag(tag,0,li);
6592 document_class=startDlg->ui.comboBoxClass->currentText();
6593 typeface_size=startDlg->ui.comboBoxSize->currentText();
6594 paper_size=startDlg->ui.comboBoxPaper->currentText();
6595 document_encoding=startDlg->ui.comboBoxEncoding->currentText();
6596 ams_packages=startDlg->ui.checkBoxAMS->isChecked();
6597 makeidx_package=startDlg->ui.checkBoxIDX->isChecked();
6598 babel_package=startDlg->ui.checkBoxBabel->isChecked();
6599 geometry_package=startDlg->ui.checkBoxGeometry->isChecked();
6600 graphicx_package=startDlg->ui.checkBoxGraphicx->isChecked();
6601 lmodern_package=startDlg->ui.checkBoxLmodern->isChecked();
6602 kpfonts_package=startDlg->ui.checkBoxKpfonts->isChecked();
6603 fourier_package=startDlg->ui.checkBoxFourier->isChecked();
6604 author=startDlg->ui.lineEditAuthor->text();
6605 geometry_options=startDlg->ui.lineEditGeometry->text();
6606 userClassList=startDlg->otherClassList;
6607 userPaperList=startDlg->otherPaperList;
6608 userEncodingList=startDlg->otherEncodingList;
6609 userOptionsList=startDlg->otherOptionsList;
6610 userBabelList=startDlg->otherBabelList;
6611 }
6612 }
6613
QuickXelatex()6614 void Texmaker::QuickXelatex()
6615 {
6616 QString opt="";
6617 QString optbabel="";
6618 int li=3;
6619 int f;
6620 if ( !currentEditorView() ) fileNew();
6621 QString tag=QString("\\documentclass[");
6622 QuickXelatexDialog *startDlg = new QuickXelatexDialog(this,"Quick Start");
6623 startDlg->otherClassList=userClassList;
6624 startDlg->otherPaperList=userPaperList;
6625 startDlg->otherOptionsList=userOptionsList;
6626 startDlg->otherBabelList=userBabelList;
6627 startDlg->Init();
6628 f=startDlg->ui.comboBoxClass->findText(document_class,Qt::MatchExactly | Qt::MatchCaseSensitive);
6629 startDlg->ui.comboBoxClass->setCurrentIndex(f);
6630 f=startDlg->ui.comboBoxSize->findText(typeface_size,Qt::MatchExactly | Qt::MatchCaseSensitive);
6631 startDlg->ui.comboBoxSize->setCurrentIndex(f);
6632 f=startDlg->ui.comboBoxPaper->findText(paper_size,Qt::MatchExactly | Qt::MatchCaseSensitive);
6633 startDlg->ui.comboBoxPaper->setCurrentIndex(f);
6634 QList<QListWidgetItem *> babItems=startDlg->ui.listWidgetBabel->findItems(babel_default,Qt::MatchExactly | Qt::MatchCaseSensitive);
6635 if (babItems.size()>0) startDlg->ui.listWidgetBabel->setCurrentItem(babItems.at(0));
6636 startDlg->ui.checkBoxAMS->setChecked(ams_packages);
6637 startDlg->ui.checkBoxBabel->setChecked(babel_package);
6638 startDlg->ui.listWidgetBabel->setEnabled(babel_package);
6639 startDlg->ui.pushButtonBabel->setEnabled(babel_package);
6640 startDlg->ui.checkBoxGeometry->setChecked(geometry_package);
6641 startDlg->ui.lineEditGeometry->setEnabled(geometry_package);
6642 startDlg->ui.checkBoxGraphicx->setChecked(graphicx_package);
6643 startDlg->ui.lineEditAuthor->setText(author);
6644 startDlg->ui.lineEditGeometry->setText(geometry_options);
6645 if ( startDlg->exec() )
6646 {
6647 tag+=startDlg->ui.comboBoxSize->currentText()+QString(",");
6648 tag+=startDlg->ui.comboBoxPaper->currentText();
6649 QList<QListWidgetItem *> selectedItems=startDlg->ui.listWidgetOptions->selectedItems();
6650 for (int i = 0; i < selectedItems.size(); ++i)
6651 {
6652 if ( selectedItems.at(i)) opt+=QString(",")+selectedItems.at(i)->text();
6653 }
6654 tag+=opt+QString("]{");
6655 tag+=startDlg->ui.comboBoxClass->currentText()+QString("}");
6656 tag+=QString("\n");
6657
6658 tag+=QString("\\usepackage{fontspec}\n");
6659 tag+=QString("\\defaultfontfeatures{Mapping=tex-text}\n");
6660 tag+=QString("\\usepackage{xunicode}\n");
6661 tag+=QString("\\usepackage{xltxtra}\n");
6662 tag+=QString("%\\setmainfont{???}\n");
6663 if (startDlg->ui.checkBoxBabel->isChecked())
6664 {
6665 QList<QListWidgetItem *> babelItems=startDlg->ui.listWidgetBabel->selectedItems();
6666 for (int i = 0; i < babelItems.size(); ++i)
6667 {
6668 if ( babelItems.at(i))
6669 {
6670 if (i==0)
6671 {
6672 optbabel+=babelItems.at(i)->text();
6673 babel_default=babelItems.at(i)->text();
6674 }
6675 }
6676 }
6677 tag+=QString("\\usepackage{polyglossia}\n\\setdefaultlanguage{"+optbabel+"}\n");
6678 li=li+1;
6679 }
6680 if (startDlg->ui.checkBoxAMS->isChecked())
6681 {
6682 tag+=QString("\\usepackage{amsmath}\n\\usepackage{amsfonts}\n\\usepackage{amssymb}\n");
6683 li=li+3;
6684 }
6685 if (startDlg->ui.checkBoxGraphicx->isChecked())
6686 {
6687 tag+=QString("\\usepackage{graphicx}\n");
6688 li=li+1;
6689 }
6690 if (startDlg->ui.checkBoxGeometry->isChecked())
6691 {
6692 tag+=QString("\\usepackage["+startDlg->ui.lineEditGeometry->text()+"]{geometry}\n");
6693 li=li+1;
6694 }
6695 if (startDlg->ui.lineEditAuthor->text()!="")
6696 {
6697 tag+="\\author{"+startDlg->ui.lineEditAuthor->text()+"}\n";
6698 li=li+1;
6699 }
6700 if (startDlg->ui.lineEditTitle->text()!="")
6701 {
6702 tag+="\\title{"+startDlg->ui.lineEditTitle->text()+"}\n";
6703 li=li+1;
6704 }
6705 tag+=QString("\\begin{document}\n\n\\end{document}");
6706 InsertTag(tag,0,li);
6707 document_class=startDlg->ui.comboBoxClass->currentText();
6708 typeface_size=startDlg->ui.comboBoxSize->currentText();
6709 paper_size=startDlg->ui.comboBoxPaper->currentText();
6710 document_encoding="utf8";
6711 ams_packages=startDlg->ui.checkBoxAMS->isChecked();
6712 babel_package=startDlg->ui.checkBoxBabel->isChecked();
6713 geometry_package=startDlg->ui.checkBoxGeometry->isChecked();
6714 graphicx_package=startDlg->ui.checkBoxGraphicx->isChecked();
6715 author=startDlg->ui.lineEditAuthor->text();
6716 geometry_options=startDlg->ui.lineEditGeometry->text();
6717 userClassList=startDlg->otherClassList;
6718 userPaperList=startDlg->otherPaperList;
6719 userOptionsList=startDlg->otherOptionsList;
6720 userBabelList=startDlg->otherBabelList;
6721 }
6722 }
6723
6724
QuickBeamer()6725 void Texmaker::QuickBeamer()
6726 {
6727 QString opt="";
6728 QString optbabel="";
6729 int f;
6730 QString fontenc="";
6731 if ( !currentEditorView() ) fileNew();
6732 QString tag=QString("\\documentclass[");
6733 QuickBeamerDialog *beamDlg = new QuickBeamerDialog(this,"Quick Start");
6734 beamDlg->Init();
6735 f=beamDlg->ui.comboBoxTheme->findText(beamer_theme,Qt::MatchExactly | Qt::MatchCaseSensitive);
6736 beamDlg->ui.comboBoxTheme->setCurrentIndex(f);
6737 f=beamDlg->ui.comboBoxSize->findText(beamer_size,Qt::MatchExactly | Qt::MatchCaseSensitive);
6738 beamDlg->ui.comboBoxSize->setCurrentIndex(f);
6739 f=beamDlg->ui.comboBoxEncoding->findText(beamer_encoding,Qt::MatchExactly | Qt::MatchCaseSensitive);
6740 beamDlg->ui.comboBoxEncoding->setCurrentIndex(f);
6741 QList<QListWidgetItem *> babItems=beamDlg->ui.listWidgetBabel->findItems(beamer_babel,Qt::MatchExactly | Qt::MatchCaseSensitive);
6742 if (babItems.size()>0) beamDlg->ui.listWidgetBabel->setCurrentItem(babItems.at(0));
6743 beamDlg->ui.checkBoxAMS->setChecked(ams_packages);
6744 beamDlg->ui.checkBoxGraphicx->setChecked(graphicx_package);
6745 beamDlg->ui.checkBoxBabel->setChecked(babel_package);
6746 beamDlg->ui.listWidgetBabel->setEnabled(babel_package);
6747 beamDlg->ui.lineEditAuthor->setText(beamer_author);
6748 if ( beamDlg->exec() )
6749 {
6750 tag+=beamDlg->ui.comboBoxSize->currentText();
6751 tag+=QString("]{beamer}\n");
6752 tag+="\\usetheme{"+beamDlg->ui.comboBoxTheme->currentText()+"}\n";
6753 if (beamDlg->ui.comboBoxEncoding->currentText()!="NONE") tag+=QString("\\usepackage[")+beamDlg->ui.comboBoxEncoding->currentText()+QString("]{inputenc}");
6754 tag+=QString("\n");
6755 if (beamDlg->ui.comboBoxEncoding->currentText().startsWith("utf8x"))
6756 {
6757 tag+=QString("\\usepackage{ucs}\n");
6758 }
6759 if (beamDlg->ui.checkBoxBabel->isChecked())
6760 {
6761 QList<QListWidgetItem *> babelItems=beamDlg->ui.listWidgetBabel->selectedItems();
6762 for (int i = 0; i < babelItems.size(); ++i)
6763 {
6764 if ( babelItems.at(i))
6765 {
6766 if ((babelItems.at(i)->text()=="arabic") && fontenc.isEmpty()) fontenc="LAE,LFE";
6767 else if ((babelItems.at(i)->text()=="russian") && fontenc.isEmpty()) fontenc="OT1";
6768 else if ((babelItems.at(i)->text()=="slovak") && fontenc.isEmpty()) fontenc="IL2";
6769 else if ((babelItems.at(i)->text()=="francais") && fontenc.isEmpty()) fontenc="T1";
6770 else if ((babelItems.at(i)->text()=="french") && fontenc.isEmpty()) fontenc="T1";
6771 else if ((babelItems.at(i)->text()=="frenchb") && fontenc.isEmpty()) fontenc="T1";
6772 else if ((babelItems.at(i)->text()=="german") && fontenc.isEmpty()) fontenc="T1";
6773 else if ((babelItems.at(i)->text()=="portuguese") && fontenc.isEmpty()) fontenc="T1";
6774 else if ((babelItems.at(i)->text()=="icelandic") && fontenc.isEmpty()) fontenc="T1";
6775 else if ((babelItems.at(i)->text()=="czech") && fontenc.isEmpty()) fontenc="T1";
6776 else if ((babelItems.at(i)->text()=="magyar") && fontenc.isEmpty()) fontenc="T1";
6777 else if ((babelItems.at(i)->text()=="finnish") && fontenc.isEmpty()) fontenc="T1";
6778 if (i==0)
6779 {
6780 optbabel+=babelItems.at(i)->text();
6781 beamer_babel=babelItems.at(i)->text();
6782 }
6783 else optbabel+=QString(",")+babelItems.at(i)->text();
6784 }
6785 }
6786 tag+=QString("\\usepackage["+optbabel+"]{babel}\n");
6787 if (!fontenc.isEmpty())
6788 {
6789 tag+=QString("\\usepackage["+fontenc+"]{fontenc}\n");
6790 }
6791 }
6792 if (beamDlg->ui.checkBoxAMS->isChecked())
6793 {
6794 tag+=QString("\\usepackage{amsmath}\n\\usepackage{amsfonts}\n\\usepackage{amssymb}\n");
6795 }
6796 if (beamDlg->ui.checkBoxGraphicx->isChecked())
6797 {
6798 tag+=QString("\\usepackage{graphicx}\n");
6799 }
6800 if (beamDlg->ui.lineEditAuthor->text()!="")
6801 {
6802 tag+="\\author{"+beamDlg->ui.lineEditAuthor->text()+"}\n";
6803 }
6804 else
6805 {
6806 tag+="%\\author{}\n";
6807 }
6808 if (beamDlg->ui.lineEditTitle->text()!="")
6809 {
6810 tag+="\\title{"+beamDlg->ui.lineEditTitle->text()+"}\n";
6811 }
6812 else
6813 {
6814 tag+="%\\title{}\n";
6815 }
6816 tag+=QString("%\\setbeamercovered{transparent} \n");
6817 tag+=QString("%\\setbeamertemplate{navigation symbols}{} \n");
6818 tag+=QString("%\\logo{} \n");
6819 tag+=QString("%\\institute{} \n");
6820 tag+=QString("%\\date{} \n");
6821 tag+=QString("%\\subject{} \n");
6822 tag+=QString("\\begin{document}\n\n");
6823 if ((beamDlg->ui.lineEditAuthor->text()!="") || (beamDlg->ui.lineEditTitle->text()!="")) tag+=QString("\\begin{frame}\n\\titlepage\n\\end{frame}\n\n");
6824 else tag+=QString("%\\begin{frame}\n%\\titlepage\n%\\end{frame}\n\n");
6825 tag+=QString("%\\begin{frame}\n%\\tableofcontents\n%\\end{frame}\n\n");
6826 tag+=QString("\\begin{frame}{"+QString(0x2022)+"}\n\n\\end{frame}\n\n");
6827 tag+=QString("\\end{document}");
6828 if (currentEditorView())
6829 {
6830 OutputTextEdit->clear();
6831 QTextCursor cur=currentEditorView()->editor->textCursor();
6832 int pos=cur.position();;
6833 currentEditorView()->editor->insertWithMemoryIndent(tag);
6834 cur.setPosition(pos,QTextCursor::MoveAnchor);
6835 currentEditorView()->editor->setTextCursor(cur);
6836 currentEditorView()->editor->search(QString(0x2022) ,true,false,true,true,false);
6837 OutputTextEdit->insertLine("Use the Tab key to reach the next "+QString(0x2022)+" field");
6838 currentEditorView()->editor->setFocus();
6839 OutputTableWidget->hide();
6840 OutputTextEdit->setMaximumHeight(splitter2->sizes().at(1));
6841 separatorline->hide();
6842 logpresent=false;
6843 }
6844 beamer_theme=beamDlg->ui.comboBoxTheme->currentText();
6845 beamer_size=beamDlg->ui.comboBoxSize->currentText();
6846 beamer_encoding=beamDlg->ui.comboBoxEncoding->currentText();
6847 ams_packages=beamDlg->ui.checkBoxAMS->isChecked();
6848 babel_package=beamDlg->ui.checkBoxBabel->isChecked();
6849 graphicx_package=beamDlg->ui.checkBoxGraphicx->isChecked();
6850 beamer_author=beamDlg->ui.lineEditAuthor->text();
6851 }
6852 }
6853
InsertBib1()6854 void Texmaker::InsertBib1()
6855 {
6856 QString tag = QString("@Article{"+QString(0x2022)+",\n");
6857 tag+="author = {},\n";
6858 tag+="title = {},\n";
6859 tag+="journal = {},\n";
6860 tag+="year = {},\n";
6861 tag+="OPTkey = {},\n";
6862 tag+="OPTvolume = {},\n";
6863 tag+="OPTnumber = {},\n";
6864 tag+="OPTpages = {},\n";
6865 tag+="OPTmonth = {},\n";
6866 tag+="OPTnote = {},\n";
6867 tag+="OPTannote = {}\n";
6868 tag+="}\n";
6869 InsertTag(tag,9,0);
6870 OutputTextEdit->insertLine("Bib fields - Article in Journal");
6871 OutputTextEdit->insertLine( "OPT.... : optional fields (use the 'Clean' command to remove them)");
6872 }
6873
InsertBib2()6874 void Texmaker::InsertBib2()
6875 {
6876 QString tag = QString("@InProceedings{"+QString(0x2022)+",\n");
6877 tag+="author = {},\n";
6878 tag+="title = {},\n";
6879 tag+="booktitle = {},\n";
6880 tag+="OPTcrossref = {},\n";
6881 tag+="OPTkey = {},\n";
6882 tag+="OPTpages = {},\n";
6883 tag+="OPTyear = {},\n";
6884 tag+="OPTeditor = {},\n";
6885 tag+="OPTvolume = {},\n";
6886 tag+="OPTnumber = {},\n";
6887 tag+="OPTseries = {},\n";
6888 tag+="OPTaddress = {},\n";
6889 tag+="OPTmonth = {},\n";
6890 tag+="OPTorganization = {},\n";
6891 tag+="OPTpublisher = {},\n";
6892 tag+="OPTnote = {},\n";
6893 tag+="OPTannote = {}\n";
6894 tag+="}\n";
6895 InsertTag(tag,15,0);
6896 OutputTextEdit->insertLine("Bib fields - Article in Conference Proceedings");
6897 OutputTextEdit->insertLine( "OPT.... : optional fields (use the 'Clean' command to remove them)");
6898 }
InsertBib3()6899 void Texmaker::InsertBib3()
6900 {
6901 QString tag = QString("@InCollection{"+QString(0x2022)+",\n");
6902 tag+="author = {},\n";
6903 tag+="title = {},\n";
6904 tag+="booktitle = {},\n";
6905 tag+="OPTcrossref = {},\n";
6906 tag+="OPTkey = {},\n";
6907 tag+="OPTpages = {},\n";
6908 tag+="OPTpublisher = {},\n";
6909 tag+="OPTyear = {},\n";
6910 tag+="OPTeditor = {},\n";
6911 tag+="OPTvolume = {},\n";
6912 tag+="OPTnumber = {},\n";
6913 tag+="OPTseries = {},\n";
6914 tag+="OPTtype = {},\n";
6915 tag+="OPTchapter = {},\n";
6916 tag+="OPTaddress = {},\n";
6917 tag+="OPTedition = {},\n";
6918 tag+="OPTmonth = {},\n";
6919 tag+="OPTnote = {},\n";
6920 tag+="OPTannote = {}\n";
6921 tag+="}\n";
6922 InsertTag(tag,14,0);
6923 OutputTextEdit->insertLine("Bib fields - Article in a Collection");
6924 OutputTextEdit->insertLine( "OPT.... : optional fields (use the 'Clean' command to remove them)");
6925 }
InsertBib4()6926 void Texmaker::InsertBib4()
6927 {
6928 QString tag = QString("@InBook{"+QString(0x2022)+",\n");
6929 tag+="ALTauthor = {},\n";
6930 tag+="ALTeditor = {},\n";
6931 tag+="title = {},\n";
6932 tag+="chapter = {},\n";
6933 tag+="publisher = {},\n";
6934 tag+="year = {},\n";
6935 tag+="OPTkey = {},\n";
6936 tag+="OPTvolume = {},\n";
6937 tag+="OPTnumber = {},\n";
6938 tag+="OPTseries = {},\n";
6939 tag+="OPTtype = {},\n";
6940 tag+="OPTaddress = {},\n";
6941 tag+="OPTedition = {},\n";
6942 tag+="OPTmonth = {},\n";
6943 tag+="OPTpages = {},\n";
6944 tag+="OPTnote = {},\n";
6945 tag+="OPTannote = {}\n";
6946 tag+="}\n";
6947 InsertTag(tag,8,0);
6948 OutputTextEdit->insertLine("Bib fields - Chapter or Pages in a Book");
6949 OutputTextEdit->insertLine( "ALT.... : you have the choice between these two fields");
6950 OutputTextEdit->insertLine( "OPT.... : optional fields (use the 'Clean' command to remove them)");
6951 }
InsertBib5()6952 void Texmaker::InsertBib5()
6953 {
6954 QString tag = QString("@Proceedings{"+QString(0x2022)+",\n");
6955 tag+="title = {},\n";
6956 tag+="year = {},\n";
6957 tag+="OPTkey = {},\n";
6958 tag+="OPTeditor = {},\n";
6959 tag+="OPTvolume = {},\n";
6960 tag+="OPTnumber = {},\n";
6961 tag+="OPTseries = {},\n";
6962 tag+="OPTaddress = {},\n";
6963 tag+="OPTmonth = {},\n";
6964 tag+="OPTorganization = {},\n";
6965 tag+="OPTpublisher = {},\n";
6966 tag+="OPTnote = {},\n";
6967 tag+="OPTannote = {}\n";
6968 tag+="}\n";
6969 InsertTag(tag,13,0);
6970 OutputTextEdit->insertLine("Bib fields - Conference Proceedings");
6971 OutputTextEdit->insertLine( "OPT.... : optional fields (use the 'Clean' command to remove them)");
6972 }
InsertBib6()6973 void Texmaker::InsertBib6()
6974 {
6975 QString tag = QString("@Book{"+QString(0x2022)+",\n");
6976 tag+="ALTauthor = {},\n";
6977 tag+="ALTeditor = {},\n";
6978 tag+="title = {},\n";
6979 tag+="publisher = {},\n";
6980 tag+="year = {},\n";
6981 tag+="OPTkey = {},\n";
6982 tag+="OPTvolume = {},\n";
6983 tag+="OPTnumber = {},\n";
6984 tag+="OPTseries = {},\n";
6985 tag+="OPTaddress = {},\n";
6986 tag+="OPTedition = {},\n";
6987 tag+="OPTmonth = {},\n";
6988 tag+="OPTnote = {},\n";
6989 tag+="OPTannote = {}\n";
6990 tag+="}\n";
6991 InsertTag(tag,6,0);
6992 OutputTextEdit->insertLine("Bib fields - Book");
6993 OutputTextEdit->insertLine( "ALT.... : you have the choice between these two fields");
6994 OutputTextEdit->insertLine( "OPT.... : optional fields (use the 'Clean' command to remove them)");
6995 }
InsertBib7()6996 void Texmaker::InsertBib7()
6997 {
6998 QString tag = QString("@Booklet{"+QString(0x2022)+",\n");
6999 tag+="title = {},\n";
7000 tag+="OPTkey = {},\n";
7001 tag+="OPTauthor = {},\n";
7002 tag+="OPThowpublished = {},\n";
7003 tag+="OPTaddress = {},\n";
7004 tag+="OPTmonth = {},\n";
7005 tag+="OPTyear = {},\n";
7006 tag+="OPTnote = {},\n";
7007 tag+="OPTannote = {}\n";
7008 tag+="}\n";
7009 InsertTag(tag,9,0);
7010 OutputTextEdit->insertLine("Bib fields - Booklet");
7011 OutputTextEdit->insertLine( "OPT.... : optional fields (use the 'Clean' command to remove them)");
7012 }
InsertBib8()7013 void Texmaker::InsertBib8()
7014 {
7015 QString tag = QString("@PhdThesis{"+QString(0x2022)+",\n");
7016 tag+="author = {},\n";
7017 tag+="title = {},\n";
7018 tag+="school = {},\n";
7019 tag+="year = {},\n";
7020 tag+="OPTkey = {},\n";
7021 tag+="OPTtype = {},\n";
7022 tag+="OPTaddress = {},\n";
7023 tag+="OPTmonth = {},\n";
7024 tag+="OPTnote = {},\n";
7025 tag+="OPTannote = {}\n";
7026 tag+="}\n";
7027 InsertTag(tag,11,0);
7028 OutputTextEdit->insertLine("Bib fields - PhD. Thesis");
7029 OutputTextEdit->insertLine( "OPT.... : optional fields (use the 'Clean' command to remove them)");
7030 }
InsertBib9()7031 void Texmaker::InsertBib9()
7032 {
7033 QString tag = QString("@MastersThesis{"+QString(0x2022)+",\n");
7034 tag+="author = {},\n";
7035 tag+="title = {},\n";
7036 tag+="school = {},\n";
7037 tag+="year = {},\n";
7038 tag+="OPTkey = {},\n";
7039 tag+="OPTtype = {},\n";
7040 tag+="OPTaddress = {},\n";
7041 tag+="OPTmonth = {},\n";
7042 tag+="OPTnote = {},\n";
7043 tag+="OPTannote = {}\n";
7044 tag+="}\n";
7045 InsertTag(tag,15,0);
7046 OutputTextEdit->insertLine("Bib fields - Master's Thesis");
7047 OutputTextEdit->insertLine( "OPT.... : optional fields (use the 'Clean' command to remove them)");
7048 }
InsertBib10()7049 void Texmaker::InsertBib10()
7050 {
7051 QString tag = QString("@TechReport{"+QString(0x2022)+",\n");
7052 tag+="author = {},\n";
7053 tag+="title = {},\n";
7054 tag+="institution = {},\n";
7055 tag+="year = {},\n";
7056 tag+="OPTkey = {},\n";
7057 tag+="OPTtype = {},\n";
7058 tag+="OPTnumber = {},\n";
7059 tag+="OPTaddress = {},\n";
7060 tag+="OPTmonth = {},\n";
7061 tag+="OPTnote = {},\n";
7062 tag+="OPTannote = {}\n";
7063 tag+="}\n";
7064 InsertTag(tag,12,0);
7065 OutputTextEdit->insertLine("Bib fields - Technical Report");
7066 OutputTextEdit->insertLine( "OPT.... : optional fields (use the 'Clean' command to remove them)");
7067 }
InsertBib11()7068 void Texmaker::InsertBib11()
7069 {
7070 QString tag = QString("@Manual{"+QString(0x2022)+",\n");
7071 tag+="title = {},\n";
7072 tag+="OPTkey = {},\n";
7073 tag+="OPTauthor = {},\n";
7074 tag+="OPTorganization = {},\n";
7075 tag+="OPTaddress = {},\n";
7076 tag+="OPTedition = {},\n";
7077 tag+="OPTmonth = {},\n";
7078 tag+="OPTyear = {},\n";
7079 tag+="OPTnote = {},\n";
7080 tag+="OPTannote = {}\n";
7081 tag+="}\n";
7082 InsertTag(tag,8,0);
7083 OutputTextEdit->insertLine("Bib fields - Technical Manual");
7084 OutputTextEdit->insertLine( "OPT.... : optional fields (use the 'Clean' command to remove them)");
7085 }
InsertBib12()7086 void Texmaker::InsertBib12()
7087 {
7088 QString tag = QString("@Unpublished{"+QString(0x2022)+",\n");
7089 tag+="author = {},\n";
7090 tag+="title = {},\n";
7091 tag+="note = {},\n";
7092 tag+="OPTkey = {},\n";
7093 tag+="OPTmonth = {},\n";
7094 tag+="OPTyear = {},\n";
7095 tag+="OPTannote = {}\n";
7096 tag+="}\n";
7097 InsertTag(tag,13,0);
7098 OutputTextEdit->insertLine("Bib fields - Unpublished");
7099 OutputTextEdit->insertLine( "OPT.... : optional fields (use the 'Clean' command to remove them)");
7100 }
InsertBib13()7101 void Texmaker::InsertBib13()
7102 {
7103 QString tag = QString("@Misc{"+QString(0x2022)+",\n");
7104 tag+="OPTkey = {},\n";
7105 tag+="OPTauthor = {},\n";
7106 tag+="OPTtitle = {},\n";
7107 tag+="OPThowpublished = {},\n";
7108 tag+="OPTmonth = {},\n";
7109 tag+="OPTyear = {},\n";
7110 tag+="OPTnote = {},\n";
7111 tag+="OPTannote = {}\n";
7112 tag+="}\n";
7113 InsertTag(tag,6,0);
7114 OutputTextEdit->insertLine("Bib fields - Miscellaneous");
7115 OutputTextEdit->insertLine( "OPT.... : optional fields (use the 'Clean' command to remove them)");
7116 }
7117
InsertBibLatex1()7118 void Texmaker::InsertBibLatex1()
7119 {
7120 QString tag = QString("@article{"+QString(0x2022)+",\n");
7121 tag+="author = {},\n";
7122 tag+="title = {},\n";
7123 tag+="journaltitle = {},\n";
7124 tag+="year = {},\n";
7125 QStringList optfields;
7126 optfields << "translator" << "annotator" << "commentator" << "subtitle" << "titleaddon" << "editor" << "editora" << "editorb" << "editorc" << "journalsubtitle" << "issuetitle" << "issuesubtitle" << "language" << "origlanguage" << "series" << "volume" << "number" << "eid" << "issue" << "month" << "pages" << "version" << "note" << "issn" << "addendum" << "pubstate" << "doi" << "eprint" << "eprintclass" << "eprinttype" << "url" << "urldate";
7127 for ( int i = 0; i <optfields.count(); i++ )
7128 {
7129 tag+="OPT"+optfields.at(i)+" = {},\n";
7130 }
7131 tag+="}\n";
7132
7133 InsertTag(tag,9,0);
7134 OutputTextEdit->insertLine("Bib fields - Article in Journal");
7135 OutputTextEdit->insertLine( "OPT.... : optional fields (use the 'Clean' command to remove them)");
7136 }
7137
InsertBibLatex2()7138 void Texmaker::InsertBibLatex2()
7139 {
7140 QString tag = QString("@book{"+QString(0x2022)+",\n");
7141 tag+="author = {},\n";
7142 tag+="title = {},\n";
7143 tag+="year = {},\n";
7144 QStringList optfields;
7145 optfields << "editor" << "editora" << "editorb" << "editorc" << "translator" << "annotator" << "commentator" << "introduction" << "foreword" << "afterword" << "subtitle" << "titleaddon" << "maintitle" << "mainsubtitle" << "maintitleaddon" << "language" << "origlanguage" << "volume" << "part" << "edition" << "volumes" << "series" << "number" << "note" << "publisher" << "location" << "isbn" << "chapter" << "pages" << "pagetotal" << "addendum" << "pubstate" << "doi" << "eprint" << "eprintclass" << "eprinttype" << "url" << "urldate";
7146 for ( int i = 0; i <optfields.count(); i++ )
7147 {
7148 tag+="OPT"+optfields.at(i)+" = {},\n";
7149 }
7150 tag+="}\n";
7151 InsertTag(tag,6,0);
7152 OutputTextEdit->insertLine("Bib fields - Single-volume book");
7153 OutputTextEdit->insertLine( "OPT.... : optional fields (use the 'Clean' command to remove them)");
7154 }
7155
InsertBibLatex3()7156 void Texmaker::InsertBibLatex3()
7157 {
7158 QString tag = QString("@mvbook{"+QString(0x2022)+",\n");
7159 tag+="author = {},\n";
7160 tag+="title = {},\n";
7161 tag+="year = {},\n";
7162 QStringList optfields;
7163 optfields << "editor" << "editora" << "editorb" << "editorc" << "translator" << "annotator" << "commentator" << "introduction" << "foreword" << "afterword" << "subtitle" << "titleaddon" << "language" << "origlanguage" << "edition" << "volumes" << "series" << "number" << "note" << "publisher" << "location" << "isbn" << "pagetotal" << "addendum" << "pubstate" << "doi" << "eprint" << "eprintclass" << "eprinttype" << "url" << "urldate";
7164 for ( int i = 0; i <optfields.count(); i++ )
7165 {
7166 tag+="OPT"+optfields.at(i)+" = {},\n";
7167 }
7168 tag+="}\n";
7169 InsertTag(tag,8,0);
7170 OutputTextEdit->insertLine("Bib fields - Multi-volume book");
7171 OutputTextEdit->insertLine( "OPT.... : optional fields (use the 'Clean' command to remove them)");
7172 }
7173
InsertBibLatex4()7174 void Texmaker::InsertBibLatex4()
7175 {
7176 QString tag = QString("@inbook{"+QString(0x2022)+",\n");
7177 tag+="author = {},\n";
7178 tag+="title = {},\n";
7179 tag+="booktitle = {},\n";
7180 tag+="year = {},\n";
7181 QStringList optfields;
7182 optfields << "bookauthor" << "editor" << "editora" << "editorb" << "editorc" << "translator" << "annotator" << "commentator" << "introduction" << "foreword" << "afterword" << "subtitle" << "titleaddon" << "maintitle" << "mainsubtitle" << "maintitleaddon" << "booksubtitle" << "booktitleaddon" << "language" << "origlanguage" << "volume" << "part" << "edition" << "volumes" << "series" << "number" << "note" << "publisher" << "location" << "isbn" << "chapter" << "pages" << "addendum" << "pubstate" << "doi" << "eprint" << "eprintclass" << "eprinttype" << "url" << "urldate";
7183 for ( int i = 0; i <optfields.count(); i++ )
7184 {
7185 tag+="OPT"+optfields.at(i)+" = {},\n";
7186 }
7187 tag+="}\n";
7188 InsertTag(tag,8,0);
7189 OutputTextEdit->insertLine("Bib fields - A part of a book");
7190 OutputTextEdit->insertLine( "OPT.... : optional fields (use the 'Clean' command to remove them)");
7191 }
7192
InsertBibLatex5()7193 void Texmaker::InsertBibLatex5()
7194 {
7195 QString tag = QString("@booklet{"+QString(0x2022)+",\n");
7196 tag+="author = {},\n";
7197 tag+="title = {},\n";
7198 tag+="year = {},\n";
7199 QStringList optfields;
7200 optfields << "subtitle" << "titleaddon" << "language" << "howpublished" << "type" << "note" << "location" << "chapter" << "pages" << "pagetotal" << "addendum" << "pubstate" << "doi" << "eprint" << "eprintclass" << "eprinttype" << "url" << "urldate";
7201 for ( int i = 0; i <optfields.count(); i++ )
7202 {
7203 tag+="OPT"+optfields.at(i)+" = {},\n";
7204 }
7205 tag+="}\n";
7206 InsertTag(tag,9,0);
7207 OutputTextEdit->insertLine("Bib fields - A book-like work without a formal publisher");
7208 OutputTextEdit->insertLine( "OPT.... : optional fields (use the 'Clean' command to remove them)");
7209 }
7210
InsertBibLatex6()7211 void Texmaker::InsertBibLatex6()
7212 {
7213 QString tag = QString("@collection{"+QString(0x2022)+",\n");
7214 tag+="editor = {},\n";
7215 tag+="title = {},\n";
7216 tag+="year = {},\n";
7217 QStringList optfields;
7218 optfields << "editora" << "editorb" << "editorc" << "translator" << "annotator" << "commentator" << "introduction" << "foreword" << "afterword" << "subtitle" << "titleaddon" << "maintitle" << "mainsubtitle" << "maintitleaddon" << "language" << "origlanguage" << "volume" << "part" << "edition" << "volumes" << "series" << "number" << "note" << "publisher" << "location" << "isbn" << "chapter" << "pages" << "pagetotal" << "addendum" << "pubstate" << "doi" << "eprint" << "eprintclass" << "eprinttype" << "url" << "urldate";
7219 for ( int i = 0; i <optfields.count(); i++ )
7220 {
7221 tag+="OPT"+optfields.at(i)+" = {},\n";
7222 }
7223 tag+="}\n";
7224 InsertTag(tag,11,0);
7225 OutputTextEdit->insertLine("Bib fields - Single-volume collection");
7226 OutputTextEdit->insertLine( "OPT.... : optional fields (use the 'Clean' command to remove them)");
7227 }
7228
InsertBibLatex7()7229 void Texmaker::InsertBibLatex7()
7230 {
7231 QString tag = QString("@mvcollection{"+QString(0x2022)+",\n");
7232 tag+="editor = {},\n";
7233 tag+="title = {},\n";
7234 tag+="year = {},\n";
7235 QStringList optfields;
7236 optfields << "editora" << "editorb" << "editorc" << "translator" << "annotator" << "commentator" << "introduction" << "foreword" << "afterword" << "subtitle" << "titleaddon" << "language" << "origlanguage" << "edition" << "volumes" << "series" << "number" << "note" << "publisher" << "location" << "isbn" << "pagetotal" << "addendum" << "pubstate" << "doi" << "eprint" << "eprintclass" << "eprinttype" << "url" << "urldate";
7237 for ( int i = 0; i <optfields.count(); i++ )
7238 {
7239 tag+="OPT"+optfields.at(i)+" = {},\n";
7240 }
7241 tag+="}\n";
7242 InsertTag(tag,13,0);
7243 OutputTextEdit->insertLine("Bib fields - Multi-volume collection");
7244 OutputTextEdit->insertLine( "OPT.... : optional fields (use the 'Clean' command to remove them)");
7245 }
7246
InsertBibLatex8()7247 void Texmaker::InsertBibLatex8()
7248 {
7249 QString tag = QString("@incollection{"+QString(0x2022)+",\n");
7250 tag+="author = {},\n";
7251 tag+="editor = {},\n";
7252 tag+="title = {},\n";
7253 tag+="booktitle = {},\n";
7254 tag+="year = {},\n";
7255 QStringList optfields;
7256 optfields << "editora" << "editorb" << "editorc" << "translator" << "annotator" << "commentator" << "introduction" << "foreword" << "afterword" << "subtitle" << "titleaddon" << "maintitle" << "mainsubtitle" << "maintitleaddon" << "booksubtitle" << "booktitleaddon" << "language" << "origlanguage" << "volume" << "part" << "edition" << "volumes" << "series" << "number" << "note" << "publisher" << "location" << "isbn" << "chapter" << "pages" << "addendum" << "pubstate" << "doi" << "eprint" << "eprintclass" << "eprinttype" << "url" << "urldate";
7257 for ( int i = 0; i <optfields.count(); i++ )
7258 {
7259 tag+="OPT"+optfields.at(i)+" = {},\n";
7260 }
7261 tag+="}\n";
7262 InsertTag(tag,13,0);
7263 OutputTextEdit->insertLine("Bib fields - A part of a collection");
7264 OutputTextEdit->insertLine( "OPT.... : optional fields (use the 'Clean' command to remove them)");
7265 }
7266
InsertBibLatex9()7267 void Texmaker::InsertBibLatex9()
7268 {
7269 QString tag = QString("@manual{"+QString(0x2022)+",\n");
7270 tag+="author = {},\n";
7271 tag+="title = {},\n";
7272 tag+="year = {},\n";
7273 QStringList optfields;
7274 optfields << "subtitle" << "titleaddon" << "language" << "edition" << "type" << "series" << "number" << "version" << "note" << "organization" << "publisher" << "location" << "isbn" << "chapter" << "pages" << "pagetotal" << "addendum" << "pubstate" << "doi" << "eprint" << "eprintclass" << "eprinttype" << "url" << "urldate";
7275 for ( int i = 0; i <optfields.count(); i++ )
7276 {
7277 tag+="OPT"+optfields.at(i)+" = {},\n";
7278 }
7279 tag+="}\n";
7280 InsertTag(tag,8,0);
7281 OutputTextEdit->insertLine("Bib fields - Technical documentation");
7282 OutputTextEdit->insertLine( "OPT.... : optional fields (use the 'Clean' command to remove them)");
7283 }
7284
InsertBibLatex10()7285 void Texmaker::InsertBibLatex10()
7286 {
7287 QString tag = QString("@misc{"+QString(0x2022)+",\n");
7288 tag+="author = {},\n";
7289 tag+="title = {},\n";
7290 tag+="year = {},\n";
7291 QStringList optfields;
7292 optfields << "subtitle" << "titleaddon" << "language" << "howpublished" << "type" << "version" << "note" << "organization" << "location" << "date" << "month" << "addendum" << "pubstate" << "doi" << "eprint" << "eprintclass" << "eprinttype" << "url" << "urldate";
7293 for ( int i = 0; i <optfields.count(); i++ )
7294 {
7295 tag+="OPT"+optfields.at(i)+" = {},\n";
7296 }
7297 tag+="}\n";
7298 InsertTag(tag,6,0);
7299 OutputTextEdit->insertLine("Bib fields - Miscellaneous");
7300 OutputTextEdit->insertLine( "OPT.... : optional fields (use the 'Clean' command to remove them)");
7301 }
7302
InsertBibLatex11()7303 void Texmaker::InsertBibLatex11()
7304 {
7305 QString tag = QString("@online{"+QString(0x2022)+",\n");
7306 tag+="author = {},\n";
7307 tag+="title = {},\n";
7308 tag+="year = {},\n";
7309 tag+="url = {},\n";
7310 QStringList optfields;
7311 optfields << "subtitle" << "titleaddon" << "language" << "version" << "note" << "organization" << "date" << "month" << "addendum" << "pubstate" << "urldate";
7312 for ( int i = 0; i <optfields.count(); i++ )
7313 {
7314 tag+="OPT"+optfields.at(i)+" = {},\n";
7315 }
7316 tag+="}\n";
7317 InsertTag(tag,8,0);
7318 OutputTextEdit->insertLine("Bib fields - Online resource");
7319 OutputTextEdit->insertLine( "OPT.... : optional fields (use the 'Clean' command to remove them)");
7320 }
7321
InsertBibLatex12()7322 void Texmaker::InsertBibLatex12()
7323 {
7324 QString tag = QString("@periodical{"+QString(0x2022)+",\n");
7325 tag+="editor = {},\n";
7326 tag+="title = {},\n";
7327 tag+="year = {},\n";
7328 QStringList optfields;
7329 optfields << "editora" << "editorb" << "editorc" << "subtitle" << "issuetitle" << "issuesubtitle" << "language" << "series" << "volume" << "number" << "issue" << "date" << "month" << "note" << "issn" << "addendum" << "pubstate" << "doi" << "eprint" << "eprintclass" << "eprinttype" << "url" << "urldate";
7330 for ( int i = 0; i <optfields.count(); i++ )
7331 {
7332 tag+="OPT"+optfields.at(i)+" = {},\n";
7333 }
7334 tag+="}\n";
7335 InsertTag(tag,11,0);
7336 OutputTextEdit->insertLine("Bib fields - Issue of a periodical");
7337 OutputTextEdit->insertLine( "OPT.... : optional fields (use the 'Clean' command to remove them)");
7338 }
7339
InsertBibLatex13()7340 void Texmaker::InsertBibLatex13()
7341 {
7342 QString tag = QString("@proceedings{"+QString(0x2022)+",\n");
7343 tag+="editor = {},\n";
7344 tag+="title = {},\n";
7345 tag+="year = {},\n";
7346 QStringList optfields;
7347 optfields << "subtitle" << "titleaddon" << "maintitle" << "mainsubtitle" << "maintitleaddon" << "eventtitle" << "eventdate" << "venue" << "language" << "volume" << "part" << "volumes" << "series" << "number" << "note" << "organization" << "publisher" << "location" << "month" << "isbn" << "chapter" << "pages" << "pagetotal" << "addendum" << "pubstate" << "doi" << "eprint" << "eprintclass" << "eprinttype" << "url" << "urldate";
7348 for ( int i = 0; i <optfields.count(); i++ )
7349 {
7350 tag+="OPT"+optfields.at(i)+" = {},\n";
7351 }
7352 tag+="}\n";
7353 InsertTag(tag,12,0);
7354 OutputTextEdit->insertLine("Bib fields - Single-volume conference proceedings");
7355 OutputTextEdit->insertLine( "OPT.... : optional fields (use the 'Clean' command to remove them)");
7356 }
7357
InsertBibLatex14()7358 void Texmaker::InsertBibLatex14()
7359 {
7360 QString tag = QString("@mvproceedings{"+QString(0x2022)+",\n");
7361 tag+="editor = {},\n";
7362 tag+="title = {},\n";
7363 tag+="year = {},\n";
7364 QStringList optfields;
7365 optfields << "subtitle" << "titleaddon" << "eventtitle" << "eventdate" << "venue" << "language" << "volumes" << "series" << "number" << "note" << "organization" << "publisher" << "location" << "month" << "isbn" << "pagetotal" << "addendum" << "pubstate" << "doi" << "eprint" << "eprintclass" << "eprinttype" << "url" << "urldate";
7366 for ( int i = 0; i <optfields.count(); i++ )
7367 {
7368 tag+="OPT"+optfields.at(i)+" = {},\n";
7369 }
7370 tag+="}\n";
7371 InsertTag(tag,14,0);
7372 OutputTextEdit->insertLine("Bib fields - Multi-volume conference proceedings");
7373 OutputTextEdit->insertLine( "OPT.... : optional fields (use the 'Clean' command to remove them)");
7374 }
7375
InsertBibLatex15()7376 void Texmaker::InsertBibLatex15()
7377 {
7378 QString tag = QString("@inproceedings{"+QString(0x2022)+",\n");
7379 tag+="author = {},\n";
7380 tag+="editor = {},\n";
7381 tag+="title = {},\n";
7382 tag+="booktitle = {},\n";
7383 tag+="year = {},\n";
7384 QStringList optfields;
7385 optfields << "subtitle" << "titleaddon" << "maintitle" << "mainsubtitle" << "maintitleaddon" << "booksubtitle" << "booktitleaddon" << "eventtitle" << "eventdate" << "venue" << "language" << "volume" << "part" << "volumes" << "series" << "number" << "note" << "organization" << "publisher" << "location" << "month" << "isbn" << "chapter" << "pages" << "addendum" << "pubstate" << "doi" << "eprint" << "eprintclass" << "eprinttype" << "url" << "urldate";
7386 for ( int i = 0; i <optfields.count(); i++ )
7387 {
7388 tag+="OPT"+optfields.at(i)+" = {},\n";
7389 }
7390 tag+="}\n";
7391 InsertTag(tag,14,0);
7392 OutputTextEdit->insertLine("Bib fields - Article in conference proceedings");
7393 OutputTextEdit->insertLine( "OPT.... : optional fields (use the 'Clean' command to remove them)");
7394 }
7395
InsertBibLatex16()7396 void Texmaker::InsertBibLatex16()
7397 {
7398 QString tag = QString("@report{"+QString(0x2022)+",\n");
7399 tag+="author = {},\n";
7400 tag+="title = {},\n";
7401 tag+="type = {},\n";
7402 tag+="institution = {},\n";
7403 tag+="year = {},\n";
7404 QStringList optfields;
7405 optfields << "subtitle" << "titleaddon" << "language" << "number" << "version" << "note" << "location" << "month" << "isrn" << "chapter" << "pages" << "pagetotal" << "addendum" << "pubstate" << "doi" << "eprint" << "eprintclass" << "eprinttype" << "url" << "urldate";
7406 for ( int i = 0; i <optfields.count(); i++ )
7407 {
7408 tag+="OPT"+optfields.at(i)+" = {},\n";
7409 }
7410 tag+="}\n";
7411 InsertTag(tag,7,0);
7412 OutputTextEdit->insertLine("Bib fields - Technical report");
7413 OutputTextEdit->insertLine( "OPT.... : optional fields (use the 'Clean' command to remove them)");
7414 }
7415
InsertBibLatex17()7416 void Texmaker::InsertBibLatex17()
7417 {
7418 QString tag = QString("@thesis{"+QString(0x2022)+",\n");
7419 tag+="author = {},\n";
7420 tag+="title = {},\n";
7421 tag+="type = {},\n";
7422 tag+="institution = {},\n";
7423 tag+="year = {},\n";
7424 QStringList optfields;
7425 optfields << "subtitle" << "titleaddon" << "language" << "note" << "location" << "month" << "isbn" << "chapter" << "pages" << "pagetotal" << "addendum" << "pubstate" << "doi" << "eprint" << "eprintclass" << "eprinttype" << "url" << "urldate";
7426 for ( int i = 0; i <optfields.count(); i++ )
7427 {
7428 tag+="OPT"+optfields.at(i)+" = {},\n";
7429 }
7430 tag+="}\n";
7431 InsertTag(tag,8,0);
7432 OutputTextEdit->insertLine("Bib fields - Thesis");
7433 OutputTextEdit->insertLine( "OPT.... : optional fields (use the 'Clean' command to remove them)");
7434 }
7435
InsertBibLatex18()7436 void Texmaker::InsertBibLatex18()
7437 {
7438 QString tag = QString("@patent{"+QString(0x2022)+",\n");
7439 tag+="author = {},\n";
7440 tag+="title = {},\n";
7441 tag+="number = {},\n";
7442 tag+="year = {},\n";
7443 QStringList optfields;
7444 optfields << "holder" << "subtitle" << "titleaddon" << "type" << "version" << "location" << "note"<< "date" << " month" << "year" << "addendum" << "pubstate" <<"doi" << "eprint" << "eprintclass" << "eprinttype" << "url"<< "urldate";
7445 for ( int i = 0; i <optfields.count(); i++ )
7446 {
7447 tag+="OPT"+optfields.at(i)+" = {},\n";
7448 }
7449 tag+="}\n";
7450 InsertTag(tag,8,0);
7451 OutputTextEdit->insertLine("Bib fields - Paten");
7452 OutputTextEdit->insertLine( "OPT.... : optional fields (use the 'Clean' command to remove them)");
7453 }
7454
CleanBib()7455 void Texmaker::CleanBib()
7456 {
7457 if ( !currentEditorView() ) return;
7458 currentEditorView()->editor->removeOptAlt();
7459 }
7460
InsertUserTag(QString Entity)7461 void Texmaker::InsertUserTag(QString Entity)
7462 {
7463 if ( !currentEditorView() ) return;
7464 QString pre=currentEditorView()->editor->beginningLine();
7465 QTextCursor cur=currentEditorView()->editor->textCursor();
7466 bool selection=cur.hasSelection();
7467 if (selection) currentEditorView()->editor->cut();
7468 int pos=cur.position();
7469
7470 QRegExp rx("(@+)");
7471 int index=0;
7472 while ((index = rx.indexIn(Entity,index)) != -1)
7473 {
7474 if (rx.cap(1)=="@") Entity.replace(rx.pos(1),1,QString(0x2022));
7475 else if (rx.cap(1)=="@@") Entity.replace(rx.pos(1),2,"@");
7476 index += rx.matchedLength();
7477 }
7478
7479 //Entity.replace("@",QString(0x2022));
7480 //if (Entity.contains("\n") && !pre.isEmpty()) Entity.replace("\n","\n"+pre);
7481 currentEditorView()->editor->insertWithMemoryIndent(Entity);
7482 cur.setPosition(pos,QTextCursor::MoveAnchor);
7483 int dx=Entity.length();
7484 if (Entity.contains(QString(0x2022)))
7485 {
7486 currentEditorView()->editor->setTextCursor(cur);
7487 currentEditorView()->editor->search(QString(0x2022) ,true,false,true,true,false);
7488 if (selection) currentEditorView()->editor->paste();
7489 }
7490 else
7491 {
7492 if (dx>0) cur.movePosition(QTextCursor::NextCharacter,QTextCursor::MoveAnchor,dx);
7493 currentEditorView()->editor->setTextCursor(cur);
7494 }
7495 currentEditorView()->editor->setFocus();
7496 OutputTextEdit->clear();
7497 OutputTableWidget->hide();
7498 OutputTextEdit->setMaximumHeight(splitter2->sizes().at(1));
7499 separatorline->hide();
7500 logpresent=false;
7501 }
7502
InsertUserTag1()7503 void Texmaker::InsertUserTag1()
7504 {
7505 if (UserMenuTag[0].left(1)=="%")
7506 {
7507 QString t=UserMenuTag[0];
7508 t=t.remove(0,1);
7509 QString s="\\begin{"+t+"}\n"+QString(0x2022)+"\n\\end{"+t+"}\n";
7510 InsertUserTag(s);
7511 }
7512 else
7513 {
7514 InsertUserTag(UserMenuTag[0]);
7515 }
7516 }
7517
InsertUserTag2()7518 void Texmaker::InsertUserTag2()
7519 {
7520 if (UserMenuTag[1].left(1)=="%")
7521 {
7522 QString t=UserMenuTag[1];
7523 t=t.remove(0,1);
7524 QString s="\\begin{"+t+"}\n"+QString(0x2022)+"\n\\end{"+t+"}\n";
7525 InsertUserTag(s);
7526 }
7527 else
7528 {
7529 InsertUserTag(UserMenuTag[1]);
7530 }
7531 }
7532
InsertUserTag3()7533 void Texmaker::InsertUserTag3()
7534 {
7535 if (UserMenuTag[2].left(1)=="%")
7536 {
7537 QString t=UserMenuTag[2];
7538 t=t.remove(0,1);
7539 QString s="\\begin{"+t+"}\n"+QString(0x2022)+"\n\\end{"+t+"}\n";
7540 InsertUserTag(s);
7541 }
7542 else
7543 {
7544 InsertUserTag(UserMenuTag[2]);
7545 }
7546 }
7547
InsertUserTag4()7548 void Texmaker::InsertUserTag4()
7549 {
7550 if (UserMenuTag[3].left(1)=="%")
7551 {
7552 QString t=UserMenuTag[3];
7553 t=t.remove(0,1);
7554 QString s="\\begin{"+t+"}\n"+QString(0x2022)+"\n\\end{"+t+"}\n";
7555 InsertUserTag(s);
7556 }
7557 else
7558 {
7559 InsertUserTag(UserMenuTag[3]);
7560 }
7561 }
7562
InsertUserTag5()7563 void Texmaker::InsertUserTag5()
7564 {
7565 if (UserMenuTag[4].left(1)=="%")
7566 {
7567 QString t=UserMenuTag[4];
7568 t=t.remove(0,1);
7569 QString s="\\begin{"+t+"}\n"+QString(0x2022)+"\n\\end{"+t+"}\n";
7570 InsertUserTag(s);
7571 }
7572 else
7573 {
7574 InsertUserTag(UserMenuTag[4]);
7575 }
7576 }
7577
InsertUserTag6()7578 void Texmaker::InsertUserTag6()
7579 {
7580 if (UserMenuTag[5].left(1)=="%")
7581 {
7582 QString t=UserMenuTag[5];
7583 t=t.remove(0,1);
7584 QString s="\\begin{"+t+"}\n"+QString(0x2022)+"\n\\end{"+t+"}\n";
7585 InsertUserTag(s);
7586 }
7587 else
7588 {
7589 InsertUserTag(UserMenuTag[5]);
7590 }
7591 }
7592
InsertUserTag7()7593 void Texmaker::InsertUserTag7()
7594 {
7595 if (UserMenuTag[6].left(1)=="%")
7596 {
7597 QString t=UserMenuTag[6];
7598 t=t.remove(0,1);
7599 QString s="\\begin{"+t+"}\n"+QString(0x2022)+"\n\\end{"+t+"}\n";
7600 InsertUserTag(s);
7601 }
7602 else
7603 {
7604 InsertUserTag(UserMenuTag[6]);
7605 }
7606 }
7607
InsertUserTag8()7608 void Texmaker::InsertUserTag8()
7609 {
7610 if (UserMenuTag[7].left(1)=="%")
7611 {
7612 QString t=UserMenuTag[7];
7613 t=t.remove(0,1);
7614 QString s="\\begin{"+t+"}\n"+QString(0x2022)+"\n\\end{"+t+"}\n";
7615 InsertUserTag(s);
7616 }
7617 else
7618 {
7619 InsertUserTag(UserMenuTag[7]);
7620 }
7621 }
7622
InsertUserTag9()7623 void Texmaker::InsertUserTag9()
7624 {
7625 if (UserMenuTag[8].left(1)=="%")
7626 {
7627 QString t=UserMenuTag[8];
7628 t=t.remove(0,1);
7629 QString s="\\begin{"+t+"}\n"+QString(0x2022)+"\n\\end{"+t+"}\n";
7630 InsertUserTag(s);
7631 }
7632 else
7633 {
7634 InsertUserTag(UserMenuTag[8]);
7635 }
7636 }
7637
InsertUserTag10()7638 void Texmaker::InsertUserTag10()
7639 {
7640 if (UserMenuTag[9].left(1)=="%")
7641 {
7642 QString t=UserMenuTag[9];
7643 t=t.remove(0,1);
7644 QString s="\\begin{"+t+"}\n"+QString(0x2022)+"\n\\end{"+t+"}\n";
7645 InsertUserTag(s);
7646 }
7647 else
7648 {
7649 InsertUserTag(UserMenuTag[9]);
7650 }
7651 }
7652
EditUserMenu()7653 void Texmaker::EditUserMenu()
7654 {
7655 QAction *Act;
7656 UserMenuDialog *umDlg = new UserMenuDialog(this,tr("Edit User &Tags"));
7657 for ( int i = 0; i <= 9; i++ )
7658 {
7659 umDlg->Name[i]=UserMenuName[i];
7660 umDlg->Tag[i]=UserMenuTag[i];
7661 }
7662 umDlg->init();
7663 if ( umDlg->exec() )
7664 {
7665 for ( int i = 0; i <= 9; i++ )
7666 {
7667 UserMenuName[i]=umDlg->Name[i];
7668 UserMenuTag[i]=umDlg->Tag[i];
7669 }
7670 user11Menu->clear();
7671 Act = new QAction("1: "+UserMenuName[0], this);
7672 Act->setShortcut(Qt::SHIFT+Qt::Key_F1);
7673 connect(Act, SIGNAL(triggered()), this, SLOT(InsertUserTag1()));
7674 user11Menu->addAction(Act);
7675 Act = new QAction("2: "+UserMenuName[1], this);
7676 Act->setShortcut(Qt::SHIFT+Qt::Key_F2);
7677 connect(Act, SIGNAL(triggered()), this, SLOT(InsertUserTag2()));
7678 user11Menu->addAction(Act);
7679 Act = new QAction("3: "+UserMenuName[2], this);
7680 Act->setShortcut(Qt::SHIFT+Qt::Key_F3);
7681 connect(Act, SIGNAL(triggered()), this, SLOT(InsertUserTag3()));
7682 user11Menu->addAction(Act);
7683 Act = new QAction("4: "+UserMenuName[3], this);
7684 Act->setShortcut(Qt::SHIFT+Qt::Key_F4);
7685 connect(Act, SIGNAL(triggered()), this, SLOT(InsertUserTag4()));
7686 user11Menu->addAction(Act);
7687 Act = new QAction("5: "+UserMenuName[4], this);
7688 Act->setShortcut(Qt::SHIFT+Qt::Key_F5);
7689 connect(Act, SIGNAL(triggered()), this, SLOT(InsertUserTag5()));
7690 user11Menu->addAction(Act);
7691 Act = new QAction("6: "+UserMenuName[5], this);
7692 Act->setShortcut(Qt::SHIFT+Qt::Key_F6);
7693 connect(Act, SIGNAL(triggered()), this, SLOT(InsertUserTag6()));
7694 user11Menu->addAction(Act);
7695 Act = new QAction("7: "+UserMenuName[6], this);
7696 Act->setShortcut(Qt::SHIFT+Qt::Key_F7);
7697 connect(Act, SIGNAL(triggered()), this, SLOT(InsertUserTag7()));
7698 user11Menu->addAction(Act);
7699 Act = new QAction("8: "+UserMenuName[7], this);
7700 Act->setShortcut(Qt::SHIFT+Qt::Key_F8);
7701 connect(Act, SIGNAL(triggered()), this, SLOT(InsertUserTag8()));
7702 user11Menu->addAction(Act);
7703 Act = new QAction("9: "+UserMenuName[8], this);
7704 Act->setShortcut(Qt::SHIFT+Qt::Key_F9);
7705 connect(Act, SIGNAL(triggered()), this, SLOT(InsertUserTag9()));
7706 user11Menu->addAction(Act);
7707 Act = new QAction("10: "+UserMenuName[9], this);
7708 Act->setShortcut(Qt::SHIFT+Qt::Key_F10);
7709 connect(Act, SIGNAL(triggered()), this, SLOT(InsertUserTag10()));
7710 user11Menu->addAction(Act);
7711 user11Menu->addSeparator();
7712 Act = new QAction(tr("Edit User &Tags"), this);
7713 connect(Act, SIGNAL(triggered()), this, SLOT(EditUserMenu()));
7714 user11Menu->addAction(Act);
7715 }
7716 }
7717
SectionCommand()7718 void Texmaker::SectionCommand()
7719 {
7720 if ( !currentEditorView() ) return;
7721 QAction *action = qobject_cast<QAction *>(sender());
7722 QString text=action->text();
7723 text.remove("&");
7724 InsertStructFromString("\\"+text);
7725 }
7726
OtherCommand()7727 void Texmaker::OtherCommand()
7728 {
7729 if ( !currentEditorView() ) return;
7730 QAction *action = qobject_cast<QAction *>(sender());
7731 QString text=action->text();
7732 text.remove("&");
7733 if (text=="label")
7734 {
7735 InsertFromString("\\label{} /7/0");
7736 return;
7737 }
7738 if (text=="ref")
7739 {
7740 InsertRef();
7741 return;
7742 }
7743 if (text=="pageref")
7744 {
7745 InsertPageRef();
7746 return;
7747 }
7748 if (text=="index")
7749 {
7750 InsertFromString("\\index{}/7/0");
7751 return;
7752 }
7753 if (text=="cite")
7754 {
7755 InsertCite();
7756 //InsertFromString("\\cite{}/6/0");
7757 return;
7758 }
7759 if (text=="footnote")
7760 {
7761 InsertFromString("\\footnote{}/10/0");
7762 return;
7763 }
7764 }
7765
InsertCite()7766 void Texmaker::InsertCite()
7767 {
7768 //UpdateStructure();
7769 QString tag="";
7770 RefDialog *refDlg = new RefDialog(this,"Bibliography Items");
7771 refDlg->ui.comboBox->addItems(bibitem);
7772 refDlg->ui.label->setText("Items");
7773 if (!bibitem.isEmpty() && refDlg->exec() )
7774 {
7775 tag="\\cite{"+refDlg->ui.comboBox->currentText()+"}";
7776 InsertTag(tag,tag.length(),0);
7777 }
7778 else InsertTag("\\cite{}",6,0);
7779 OutputTextEdit->insertLine( "\\cite{bibiliography item}");
7780 }
7781
InsertRef()7782 void Texmaker::InsertRef()
7783 {
7784 //UpdateStructure();
7785 QString tag="";
7786 RefDialog *refDlg = new RefDialog(this,"Labels");
7787 refDlg->ui.comboBox->addItems(labelitem);
7788 if (!labelitem.isEmpty() && refDlg->exec() )
7789 {
7790 tag="\\ref{"+refDlg->ui.comboBox->currentText()+"}";
7791 InsertTag(tag,tag.length(),0);
7792 }
7793 else InsertTag("\\ref{}",5,0);
7794 OutputTextEdit->insertLine( "\\ref{key}");
7795 }
7796
InsertPageRef()7797 void Texmaker::InsertPageRef()
7798 {
7799 //UpdateStructure();
7800 QString tag="";
7801 RefDialog *refDlg = new RefDialog(this,"Labels");
7802 refDlg->ui.comboBox->addItems(labelitem);
7803 if (!labelitem.isEmpty() && refDlg->exec() )
7804 {
7805 tag="\\pageref{"+refDlg->ui.comboBox->currentText()+"}";
7806 InsertTag(tag,tag.length(),0);
7807 }
7808 else InsertTag("\\pageref{}",9,0);
7809 OutputTextEdit->insertLine( "\\pageref{key}");
7810 }
7811
SizeCommand()7812 void Texmaker::SizeCommand()
7813 {
7814
7815 if ( !currentEditorView() ) return;
7816 QAction *action = qobject_cast<QAction *>(sender());
7817 QString text=action->text();
7818 text.remove("&");
7819 if (text=="tiny")
7820 {
7821 if (currentEditorView()->editor->textCursor().hasSelection() && !currentEditorView()->editor->textCursor().selectedText().contains(QString(0x2029)))
7822 {
7823 InsertWithSelectionFromString("{\\tiny /}/7/0");
7824 }
7825 else InsertWithSelectionFromString("\\begin{tiny}\n/\n\\end{tiny}/12/0");
7826 return;
7827 }
7828 if (text=="scriptsize")
7829 {
7830 if (currentEditorView()->editor->textCursor().hasSelection() && !currentEditorView()->editor->textCursor().selectedText().contains(QString(0x2029)))
7831 {
7832 InsertWithSelectionFromString("{\\scriptsize /}/13/0");
7833 }
7834 else InsertWithSelectionFromString("\\begin{scriptsize}\n/\n\\end{scriptsize}/18/0");
7835 return;
7836 }
7837 if (text=="footnotesize")
7838 {
7839 if (currentEditorView()->editor->textCursor().hasSelection() && !currentEditorView()->editor->textCursor().selectedText().contains(QString(0x2029)))
7840 {
7841 InsertWithSelectionFromString("{\\footnotesize /}/15/0");
7842 }
7843 else InsertWithSelectionFromString("\\begin{footnotesize}\n/\n\\end{footnotesize}/20/0");
7844 return;
7845 }
7846 if (text=="small")
7847 {
7848 if (currentEditorView()->editor->textCursor().hasSelection() && !currentEditorView()->editor->textCursor().selectedText().contains(QString(0x2029)))
7849 {
7850 InsertWithSelectionFromString("{\\small /}/8/0");
7851 }
7852 else InsertWithSelectionFromString("\\begin{small}\n/\n\\end{small}/13/0");
7853 return;
7854 }
7855 if (text=="normalsize")
7856 {
7857 if (currentEditorView()->editor->textCursor().hasSelection() && !currentEditorView()->editor->textCursor().selectedText().contains(QString(0x2029)))
7858 {
7859 InsertWithSelectionFromString("{\\normalsize /}/13/0");
7860 }
7861 else InsertWithSelectionFromString("\\begin{normalsize}\n/\n\\end{normalsize}/18/0");
7862 return;
7863 }
7864 if (text=="large")
7865 {
7866 if (currentEditorView()->editor->textCursor().hasSelection() && !currentEditorView()->editor->textCursor().selectedText().contains(QString(0x2029)))
7867 {
7868 InsertWithSelectionFromString("{\\large /}/8/0");
7869 }
7870 else InsertWithSelectionFromString("\\begin{large}\n/\n\\end{large}/13/0");
7871 return;
7872 }
7873 if (text=="Large")
7874 {
7875 if (currentEditorView()->editor->textCursor().hasSelection() && !currentEditorView()->editor->textCursor().selectedText().contains(QString(0x2029)))
7876 {
7877 InsertWithSelectionFromString("{\\Large /}/8/0");
7878 }
7879 else InsertWithSelectionFromString("\\begin{Large}\n/\n\\end{Large}/13/0");
7880 return;
7881 }
7882 if (text=="LARGE")
7883 {
7884 if (currentEditorView()->editor->textCursor().hasSelection() && !currentEditorView()->editor->textCursor().selectedText().contains(QString(0x2029)))
7885 {
7886 InsertWithSelectionFromString("{\\LARGE /}/8/0");
7887 }
7888 else InsertWithSelectionFromString("\\begin{LARGE}\n/\n\\end{LARGE}/13/0");
7889 return;
7890 }
7891 if (text=="huge")
7892 {
7893 if (currentEditorView()->editor->textCursor().hasSelection() && !currentEditorView()->editor->textCursor().selectedText().contains(QString(0x2029)))
7894 {
7895 InsertWithSelectionFromString("{\\huge /}/7/0");
7896 }
7897 else InsertWithSelectionFromString("\\begin{huge}\n/\n\\end{huge}/12/0");
7898 return;
7899 }
7900 if (text=="Huge")
7901 {
7902 if (currentEditorView()->editor->textCursor().hasSelection() && !currentEditorView()->editor->textCursor().selectedText().contains(QString(0x2029)))
7903 {
7904 InsertWithSelectionFromString("{\\Huge /}/7/0");
7905 }
7906 else InsertWithSelectionFromString("\\begin{Huge}\n/\n\\end{Huge}/12/0");
7907 return;
7908 }
7909 }
ShowSectionMenu()7910 void Texmaker::ShowSectionMenu()
7911 {
7912 QAction *action = qobject_cast<QAction *>(sender());
7913 sectionMenu->exec(centralToolBar->widgetForAction(action)->mapToGlobal(QPoint(centralToolBar->width(),0)));
7914 }
ShowRefMenu()7915 void Texmaker::ShowRefMenu()
7916 {
7917 QAction *action = qobject_cast<QAction *>(sender());
7918 refMenu->exec(centralToolBar->widgetForAction(action)->mapToGlobal(QPoint(centralToolBar->width(),0)));
7919 }
ShowSizeMenu()7920 void Texmaker::ShowSizeMenu()
7921 {
7922 QAction *action = qobject_cast<QAction *>(sender());
7923 sizeMenu->exec(centralToolBar->widgetForAction(action)->mapToGlobal(QPoint(centralToolBar->width(),0)));
7924 }
7925
7926 ///////////////TOOLS////////////////////
RunCommand(QString comd,bool waitendprocess)7927 void Texmaker::RunCommand(QString comd,bool waitendprocess)
7928 {
7929 QString finame;
7930 QString commandline=comd;
7931 QByteArray result;
7932 if (singlemode) {finame=getName();}
7933 else {finame=MasterName;}
7934 if ((singlemode && !currentEditorView()) || finame=="")
7935 {
7936 QMessageBox::warning( this,tr("Error"),tr("Can't detect the file name"));
7937 return;
7938 }
7939 if (finame.startsWith("untitled"))
7940 {
7941 QMessageBox::warning( this,tr("Error"),tr("A document must be saved with an extension (and without spaces or accents in the name) before being used by a command."));
7942 return;
7943 }
7944 if (!currentfileSaved())
7945 {
7946 ERRPROCESS=true;
7947 return;
7948 }
7949 // QFileInfo texfi(finame);
7950 // QString suf="."+texfi.suffix();
7951 // QString realname;
7952 if ((comd.startsWith("latex") || comd.startsWith("pdflatex")) && useoutputdir)
7953 {
7954 commandline.replace("latex","latex --output-directory=build");
7955 createBuildSubdirectory(finame);
7956 // realname=finame;
7957 }
7958 // else
7959 // {
7960 // realname=outputName(finame,suf);
7961 // }
7962 //
7963 // qDebug() << realname;
7964 QFileInfo fi(finame);
7965 QString basename=fi.completeBaseName();
7966
7967
7968
7969 //commandline.replace("%","\""+basename+"\"");
7970 //commandline.replace("!",fi.absolutePath());
7971 QFileInfo ficur(getName());
7972 //if (!commandline.contains("okular")) commandline.replace("#","\""+ficur.completeBaseName()+"\"");
7973 int currentline=1;
7974 int currentcol=1;
7975 if (currentEditorView() )
7976 {
7977 currentline=currentEditorView()->editor->linefromblock(currentEditorView()->editor->textCursor().block());
7978 currentcol=currentEditorView()->editor->textCursor().position() - currentEditorView()->editor->textCursor().block().position()+1;
7979 }
7980 //commandline.replace("@",QString::number(currentline));
7981
7982
7983 QRegExp rx1("(#+)");
7984 QString capt="";
7985 if (rx1.indexIn(commandline) != -1) capt=rx1.cap(1);
7986 if (capt=="#") commandline.replace("#","\""+ficur.completeBaseName()+"\"");
7987 else if (capt=="##") commandline.replace("##","#");
7988
7989 QRegExp rx2("(%+)");
7990 capt="";
7991 if (rx2.indexIn(commandline) != -1) capt=rx2.cap(1);
7992 if (capt=="%") commandline.replace("%","\""+basename+"\"");
7993 else if (capt=="%%") commandline.replace("%%","%");
7994
7995 QRegExp rx3("(!+)");
7996 capt="";
7997 if (rx3.indexIn(commandline) != -1) capt=rx3.cap(1);
7998 if (capt=="!") commandline.replace("!",fi.absolutePath());
7999 else if (capt=="!!") commandline.replace("!!","!");
8000
8001 QRegExp rx4("(@+)");
8002 capt="";
8003 if (rx4.indexIn(commandline) != -1) capt=rx4.cap(1);
8004 if (capt=="@") commandline.replace("@",QString::number(currentline));
8005 else if (capt=="@@") commandline.replace("@@","@");
8006
8007 if (builtinpdfview && (comd==viewpdf_command))
8008 {
8009 if (embedinternalpdf)
8010 {
8011 if (pdfviewerWidget)
8012 {
8013 pdfviewerWidget->openFile(outputName(finame,".pdf"),viewpdf_command,ghostscript_command);
8014 StackedViewers->setCurrentWidget(pdfviewerWidget);
8015 //pdfviewerWidget->raise();
8016 showpdfview=true;
8017 ShowPdfView(false);
8018 pdfviewerWidget->show();
8019 if ( (pdflatex_command.contains("synctex=1")) || (latex_command.contains("synctex=1")) || (xelatex_command.contains("synctex=1")) ) pdfviewerWidget->jumpToPdfFromSource(getName(),currentline,currentcol);
8020 }
8021 else
8022 {
8023 // pdfviewerWidget=new PdfViewer(outputName(finame,".pdf"),viewpdf_command, this);
8024 pdfviewerWidget=new PdfViewerWidget(outputName(finame,".pdf"),viewpdf_command,ghostscript_command,lp_options,QKeySequence(keyToggleFocus),pdfCheckerLang,lastScale,StackedViewers);
8025 pdfviewerWidget->centralToolBarBis->setMinimumHeight(centralToolBarBis->height());
8026 pdfviewerWidget->centralToolBarBis->setMaximumHeight(centralToolBarBis->height());
8027 connect(pdfviewerWidget, SIGNAL(openDocAtLine(const QString&, int, bool)), this, SLOT(fileOpenAndGoto(const QString&, int, bool)));
8028 connect(pdfviewerWidget, SIGNAL(sendFocusToEditor()), this, SLOT(getFocusToEditor()));
8029 connect(pdfviewerWidget, SIGNAL(sendPaperSize(const QString&)), this, SLOT(setPrintPaperSize(const QString&)));
8030 StackedViewers->addWidget(pdfviewerWidget);
8031 StackedViewers->setCurrentWidget(pdfviewerWidget);
8032 //pdfviewerWidget->raise();
8033 pdfviewerWidget->show();
8034 pdfviewerWidget->openFile(outputName(finame,".pdf"),viewpdf_command,ghostscript_command);
8035 if ( (pdflatex_command.contains("synctex=1")) || (latex_command.contains("synctex=1")) || (xelatex_command.contains("synctex=1")) ) pdfviewerWidget->jumpToPdfFromSource(getName(),currentline,currentcol);
8036 }
8037 return;
8038 }
8039 else
8040 {
8041 if (pdfviewerWindow)
8042 {
8043 pdfviewerWindow->openFile(outputName(finame,".pdf"),viewpdf_command,ghostscript_command);
8044 pdfviewerWindow->raise();
8045 pdfviewerWindow->show();
8046 if ( (pdflatex_command.contains("synctex=1")) || (latex_command.contains("synctex=1")) || (xelatex_command.contains("synctex=1"))) pdfviewerWindow->jumpToPdfFromSource(getName(),currentline,currentcol);
8047 }
8048 else
8049 {
8050 // pdfviewerWindow=new PdfViewer(outputName(finame,".pdf"),viewpdf_command, this);
8051 pdfviewerWindow=new PdfViewer(outputName(finame,".pdf"),viewpdf_command,ghostscript_command,lp_options,QKeySequence(keyToggleFocus),pdfCheckerLang,lastScale,0);
8052 connect(pdfviewerWindow, SIGNAL(openDocAtLine(const QString&, int, bool)), this, SLOT(fileOpenAndGoto(const QString&, int, bool)));
8053 connect(pdfviewerWindow, SIGNAL(sendFocusToEditor()), this, SLOT(getFocusToEditor()));
8054 connect(pdfviewerWindow, SIGNAL(sendPaperSize(const QString&)), this, SLOT(setPrintPaperSize(const QString&)));
8055 pdfviewerWindow->raise();
8056 pdfviewerWindow->show();
8057 if ( (pdflatex_command.contains("synctex=1")) || (latex_command.contains("synctex=1")) || (xelatex_command.contains("synctex=1"))) pdfviewerWindow->jumpToPdfFromSource(getName(),currentline,currentcol);
8058 }
8059 return;
8060 }
8061 }
8062 else if (comd==asymptote_command)
8063 {
8064 QDir currentdir(fi.absolutePath());
8065 foreach (QFileInfo asyFileInfo, currentdir.entryInfoList(QStringList(basename+"*.asy"),QDir::Files | QDir::Readable, QDir::Name | QDir::IgnoreCase))
8066 {
8067 QString asyName = asyFileInfo.absolutePath()+"/"+asyFileInfo.completeBaseName();
8068 AsyFile(asyName);
8069 }
8070 return;
8071 }
8072
8073
8074 proc = new QProcess( this );
8075 proc->setWorkingDirectory(fi.absolutePath());
8076 proc->setProperty("command",commandline);
8077
8078 //****
8079 #if defined(Q_OS_MAC)
8080 QProcessEnvironment env = QProcessEnvironment::systemEnvironment();
8081 if (extra_path.isEmpty()) env.insert("PATH", env.value("PATH") + ":/Library/TeX/texbin:/Library/TeX/Distributions/.DefaultTeX/Contents/Programs/texbin:/usr/bin:/usr/sbin:/sbin:/usr/local/bin:/usr/texbin:/sw/bin:");
8082 else
8083 env.insert("PATH", env.value("PATH") + ":/Library/TeX/texbin:/Library/TeX/Distributions/.DefaultTeX/Contents/Programs/texbin:/usr/bin:/usr/sbin:/sbin:/usr/local/bin:/usr/texbin:/sw/bin:"+extra_path);
8084 proc->setProcessEnvironment(env);
8085 #endif
8086 #if defined(Q_OS_WIN32)
8087 QProcessEnvironment env = QProcessEnvironment::systemEnvironment();
8088 // if (extra_path.isEmpty()) env.insert("PATH", env.value("PATH") + ";c:/texlive/2018/bin;c:/texlive/2017/bin;c:/texlive/2016/bin;c:/texlive/2015/bin;c:/texlive/2014/bin;c:/texlive/2013/bin;c:/texlive/2012/bin;c:/texlive/2011/bin;c:/texlive/2010/bin;c:/w32tex/bin;c:/Program Files/MiKTeX 3.0/miktex/bin;c:/Program Files (x86)/MiKTeX 3.0/miktex/bin;c:/Program Files/MiKTeX 2.9/miktex/bin;c:/Program Files (x86)/MiKTeX 2.9/miktex/bin;c:/Program Files/MiKTeX 2.8/miktex/bin;c:/Program Files (x86)/MiKTeX 2.8/miktex/bin");
8089 // else
8090 // env.insert("PATH", env.value("PATH") + ";c:/texlive/2018/bin;c:/texlive/2017/bin;c:/texlive/2016/bin;c:/texlive/2015/bin;c:/texlive/2014/bin;c:/texlive/2013/bin;c:/texlive/2012/bin;c:/texlive/2011/bin;c:/texlive/2010/bin;c:/w32tex/bin;c:/Program Files/MiKTeX 3.0/miktex/bin;c:/Program Files (x86)/MiKTeX 3.0/miktex/bin;c:/Program Files/MiKTeX 2.9/miktex/bin;c:/Program Files (x86)/MiKTeX 2.9/miktex/bin;c:/Program Files/MiKTeX 2.8/miktex/bin;c:/Program Files (x86)/MiKTeX 2.8/miktex/bin;"+extra_path);
8091 if (!extra_path.isEmpty())
8092 {
8093 env.insert("PATH", env.value("PATH") + ";"+extra_path);
8094 proc->setProcessEnvironment(env);
8095 }
8096 #endif
8097 #if defined(Q_OS_UNIX) && !defined(Q_OS_MAC)
8098 QProcessEnvironment env = QProcessEnvironment::systemEnvironment();
8099 if (!extra_path.isEmpty())
8100 {
8101 env.insert("PATH", env.value("PATH") + ":"+extra_path);
8102 proc->setProcessEnvironment(env);
8103 }
8104 #endif
8105 qputenv("PATH", env.value("PATH").toLatin1());
8106 //****
8107 connect(proc, SIGNAL(readyReadStandardError()),this, SLOT(readFromStderr()));
8108 if ((comd==asymptote_command) || (comd==bibtex_command) ) connect(proc, SIGNAL(readyReadStandardOutput()),this, SLOT(readFromStdoutput()));
8109 if (checkViewerInstance && ((comd==viewdvi_command) || (comd==viewps_command) || (comd==viewpdf_command)))
8110 {
8111 connect(proc, SIGNAL(finished(int)),this, SLOT(SlotEndViewerProcess(int)));
8112 if (singleviewerinstance)
8113 {
8114 if (listViewerCommands.contains(commandline)) return;
8115 else listViewerCommands.append(commandline);
8116 }
8117 else
8118 {
8119 listViewerCommands.clear();
8120 }
8121 }
8122 else
8123 {
8124 if (((comd!=viewdvi_command) && (comd!=viewps_command) && (comd!=viewpdf_command))) disableToolsActions();
8125 connect(proc, SIGNAL(finished(int)),this, SLOT(SlotEndProcess(int)));
8126 }
8127 OutputTextEdit->clear();
8128 OutputTableWidget->hide();
8129 OutputTextEdit->setMaximumHeight(splitter2->sizes().at(1));
8130 separatorline->hide();
8131
8132 //OutputTextEdit->insertLine(commandline+"\n");
8133 proc->start(commandline);
8134 if (!proc->waitForStarted(1000))
8135 {
8136 ERRPROCESS=true;
8137 OutputTextEdit->insertLine("Error : could not start the command : "+commandline+"\n");
8138 checkViewerInstance=false;
8139 return;
8140 }
8141 else OutputTextEdit->insertLine("Process started\n");
8142 stat2->setText(commandline.section(' ',0,0));
8143 FINPROCESS=false;
8144 STOPPROCESS=false;
8145 if (waitendprocess)
8146 {
8147 StopAct->setEnabled(true);
8148 QApplication::setOverrideCursor(QCursor(Qt::WaitCursor));
8149 while (!FINPROCESS)
8150 {
8151 qApp->instance()->processEvents(QEventLoop::AllEvents);
8152 if (STOPPROCESS && proc && proc->state()==QProcess::Running)
8153 {
8154 proc->kill();
8155 FINPROCESS=true;
8156 ERRPROCESS=true;
8157 stat2->setText("Ready");
8158 }
8159 }
8160 QApplication::restoreOverrideCursor();
8161 enableToolsActions();
8162 StopAct->setEnabled(false);
8163 }
8164 }
8165
readFromStderr()8166 void Texmaker::readFromStderr()
8167 {
8168 QByteArray result=proc->readAllStandardError();
8169 QString t=QString(result);
8170 t=t.simplified();
8171 if (!t.isEmpty()) OutputTextEdit->insertLine(t+"\n");
8172 }
8173
stopProcess()8174 void Texmaker::stopProcess()
8175 {
8176 STOPPROCESS=true;
8177 }
readFromStdoutput()8178 void Texmaker::readFromStdoutput()
8179 {
8180 QByteArray result=proc->readAllStandardOutput ();
8181 QString t=QString(result);
8182 t=t.simplified();
8183 if (!t.isEmpty()) OutputTextEdit->insertLine(t+"\n");
8184 }
8185
SlotEndProcess(int err)8186 void Texmaker::SlotEndProcess(int err)
8187 {
8188 FINPROCESS=true;
8189 enableToolsActions();
8190 QString result=((err) ? "Process exited with error(s)" : "Process exited normally");
8191 if (err) {ERRPROCESS=true;checkViewerInstance=false;}
8192 OutputTextEdit->insertLine(result);
8193 stat2->setText("Ready");
8194 //stat2->setText(QString(" %1 ").arg(tr("Ready")));
8195 }
8196
SlotEndViewerProcess(int err)8197 void Texmaker::SlotEndViewerProcess(int err)
8198 {
8199 QString commandline = static_cast<QProcess*>(sender())->property("command").toString();
8200 if ((singleviewerinstance) && (listViewerCommands.contains(commandline))) listViewerCommands.removeAll(commandline);
8201 FINPROCESS=true;
8202 enableToolsActions();
8203 QString result=((err) ? "Process exited with error(s)" : "Process exited normally");
8204 if (err) {ERRPROCESS=true;checkViewerInstance=false;}
8205 OutputTextEdit->insertLine(result);
8206 //stat2->setText(QString(" %1 ").arg(tr("Ready")));
8207 }
8208
QuickBuild()8209 void Texmaker::QuickBuild()
8210 {
8211 //stat2->setText(QString(" %1 ").arg(tr("Quick Build")));
8212 ERRPROCESS=false;
8213 checkViewerInstance=true;
8214 QString finame=getName();
8215 QFileInfo fi(finame);
8216 if (!finame.startsWith("untitled") && finame!="" && fi.suffix()=="asy")
8217 {
8218 QStringList asyCommandList=quick_asy_command.split("|");
8219 for (int i = 0; i < asyCommandList.size(); ++i)
8220 {
8221 if ((!ERRPROCESS)&&(!asyCommandList.at(i).isEmpty()))
8222 {
8223 RunCommand(asyCommandList.at(i),true);
8224 if ((asyCommandList.at(i)==latex_command) || (asyCommandList.at(i)==pdflatex_command) || (asyCommandList.at(i)==xelatex_command) || (asyCommandList.at(i)==lualatex_command))
8225 {
8226 LoadLog();
8227 if (showoutputview) ViewLog();
8228 if (!NoLatexErrors()) NextError();
8229 }
8230 }
8231 else {checkViewerInstance=false;return;}
8232 }
8233 }
8234 else
8235 {
8236 switch (quickmode)
8237 {
8238 case 1:
8239 {
8240 //stat2->setText(QString(" %1 ").arg("Latex"));
8241 RunCommand(latex_command,true);
8242 if (ERRPROCESS && !LogExists())
8243 {
8244 QMessageBox::warning( this,tr("Error"),tr("Could not start the command.")+"\n"+latex_command);
8245 checkViewerInstance=false;
8246 return;
8247 }
8248 LoadLog();
8249 if (showoutputview) ViewLog();
8250 if (NoLatexErrors())
8251 {
8252 //stat2->setText(QString(" %1 ").arg("Dvips"));
8253 if (!ERRPROCESS) RunCommand(dvips_command,true);
8254 else {checkViewerInstance=false;return;}
8255 if (!ERRPROCESS) ViewPS();
8256 else {checkViewerInstance=false;return;}
8257 }
8258 else {NextError();}
8259 }break;
8260 case 2:
8261 {
8262 //stat2->setText(QString(" %1 ").arg("Latex"));
8263 RunCommand(latex_command,true);
8264 if (ERRPROCESS && !LogExists())
8265 {
8266 QMessageBox::warning( this,tr("Error"),tr("Could not start the command.")+"\n"+latex_command);
8267 checkViewerInstance=false;
8268 return;
8269 }
8270 LoadLog();
8271 if (showoutputview) ViewLog();
8272 if (NoLatexErrors())
8273 {
8274 if (!ERRPROCESS) ViewDvi();
8275 else {checkViewerInstance=false;return;}
8276 }
8277 else {NextError();}
8278 }break;
8279 case 3:
8280 {
8281 //stat2->setText(QString(" %1 ").arg("Pdf Latex"));
8282 RunCommand(pdflatex_command,true);
8283 if (ERRPROCESS && !LogExists())
8284 {
8285 QMessageBox::warning( this,tr("Error"),tr("Could not start the command.")+"\n"+pdflatex_command);
8286 checkViewerInstance=false;
8287 return;
8288 }
8289 LoadLog();
8290 if (showoutputview) ViewLog();
8291 if (NoLatexErrors())
8292 {
8293 if (!ERRPROCESS) ViewPDF();
8294 else {checkViewerInstance=false;return;}
8295 }
8296 else {NextError();}
8297 }break;
8298 case 4:
8299 {
8300 //stat2->setText(QString(" %1 ").arg("Latex"));
8301 RunCommand(latex_command,true);
8302 if (ERRPROCESS && !LogExists())
8303 {
8304 QMessageBox::warning( this,tr("Error"),tr("Could not start the command.")+"\n"+latex_command);
8305 checkViewerInstance=false;
8306 return;
8307 }
8308 LoadLog();
8309 if (showoutputview) ViewLog();
8310 if (NoLatexErrors())
8311 {
8312 //stat2->setText(QString(" %1 ").arg("Dvi to Pdf"));
8313 if (!ERRPROCESS) RunCommand(dvipdf_command,true);
8314 else {checkViewerInstance=false;return;}
8315 if (!ERRPROCESS) ViewPDF();
8316 else {checkViewerInstance=false;return;}
8317 }
8318 else {NextError();}
8319 }break;
8320 case 5:
8321 {
8322 //stat2->setText(QString(" %1 ").arg("Latex"));
8323 RunCommand(latex_command,true);
8324 if (ERRPROCESS && !LogExists())
8325 {
8326 QMessageBox::warning( this,tr("Error"),tr("Could not start the command.")+"\n"+latex_command);
8327 checkViewerInstance=false;
8328 return;
8329 }
8330 LoadLog();
8331 if (showoutputview) ViewLog();
8332 if (NoLatexErrors())
8333 {
8334 //stat2->setText(QString(" %1 ").arg("Dvips"));
8335 if (!ERRPROCESS) RunCommand(dvips_command,true);
8336 else {checkViewerInstance=false;return;}
8337 //stat2->setText(QString(" %1 ").arg("Ps to Pdf"));
8338 if (!ERRPROCESS) RunCommand(ps2pdf_command,true);
8339 else {checkViewerInstance=false;return;}
8340 if (!ERRPROCESS) ViewPDF();
8341 }
8342 else {NextError();}
8343 }break;
8344 case 6:
8345 {
8346 QStringList commandList=userquick_command.split("|");
8347 for (int i = 0; i < commandList.size(); ++i)
8348 {
8349 if ((!ERRPROCESS)&&(!commandList.at(i).isEmpty()))
8350 {
8351 RunCommand(commandList.at(i),true);
8352 if ((commandList.at(i)==latex_command) || (commandList.at(i)==pdflatex_command) || (commandList.at(i)==xelatex_command) || (commandList.at(i)==lualatex_command))
8353 {
8354 LoadLog();
8355 if (showoutputview) ViewLog();
8356 if (!NoLatexErrors()) NextError();
8357 }
8358 }
8359 else {checkViewerInstance=false;return;}
8360 }
8361 }break;
8362 case 7:
8363 {
8364 //stat2->setText(QString(" %1 ").arg("Latex"));
8365 RunCommand(latex_command,true);
8366 if (ERRPROCESS && !LogExists())
8367 {
8368 QMessageBox::warning( this,tr("Error"),tr("Could not start the command.")+"\n"+latex_command);
8369 checkViewerInstance=false;
8370 return;
8371 }
8372 LoadLog();
8373 if (showoutputview) ViewLog();
8374 if (NoLatexErrors())
8375 {
8376 //stat2->setText(QString(" %1 ").arg("Asymptote"));
8377 if (!ERRPROCESS) RunCommand(asymptote_command,true);
8378 else {checkViewerInstance=false;return;}
8379 if (!ERRPROCESS)
8380 {
8381 //stat2->setText(QString(" %1 ").arg("Pdf Latex"));
8382 RunCommand(latex_command,true);
8383 if (ERRPROCESS && !LogExists())
8384 {
8385 QMessageBox::warning( this,tr("Error"),tr("Could not start the command.")+"\n"+latex_command);
8386 checkViewerInstance=false;
8387 return;
8388 }
8389 LoadLog();
8390 if (showoutputview) ViewLog();
8391 if (NoLatexErrors())
8392 {
8393 RunCommand(latex_command,true);
8394 if (ERRPROCESS && !LogExists())
8395 {
8396 QMessageBox::warning( this,tr("Error"),tr("Could not start the command.")+"\n"+latex_command);
8397 checkViewerInstance=false;
8398 return;
8399 }
8400 LoadLog();
8401 if (showoutputview) ViewLog();
8402 if (NoLatexErrors())
8403 {
8404 //stat2->setText(QString(" %1 ").arg("Dvips"));
8405 if (!ERRPROCESS) RunCommand(dvips_command,true);
8406 else {checkViewerInstance=false;return;}
8407 if (!ERRPROCESS) ViewPS();
8408 else {checkViewerInstance=false;return;}
8409 }
8410 else {NextError();}
8411 }
8412 else {NextError();}
8413 }
8414 else return;
8415 // if (!ERRPROCESS)
8416 // {
8417 // //stat2->setText(QString(" %1 ").arg("Latex"));
8418 // RunCommand(latex_command,true);
8419 // if (ERRPROCESS && !LogExists())
8420 // {
8421 // QMessageBox::warning( this,tr("Error"),tr("Could not start the command."));
8422 // checkViewerInstance=false;
8423 // return;
8424 // }
8425 // LoadLog();
8426 // if (showoutputview) ViewLog();
8427 // if (NoLatexErrors())
8428 // {
8429 // //stat2->setText(QString(" %1 ").arg("Dvips"));
8430 // if (!ERRPROCESS) RunCommand(dvips_command,true);
8431 // else {checkViewerInstance=false;return;}
8432 // if (!ERRPROCESS) ViewPS();
8433 // else {checkViewerInstance=false;return;}
8434 // }
8435 // else {NextError();}
8436 // }
8437 // else return;
8438 }
8439 else {NextError();}
8440 }break;
8441 case 8:
8442 {
8443 //stat2->setText(QString(" %1 ").arg("Pdf Latex"));
8444 RunCommand(pdflatex_command,true);
8445 if (ERRPROCESS && !LogExists())
8446 {
8447 QMessageBox::warning( this,tr("Error"),tr("Could not start the command.")+"\n"+pdflatex_command);
8448 checkViewerInstance=false;
8449 return;
8450 }
8451 LoadLog();
8452 if (showoutputview) ViewLog();
8453 if (NoLatexErrors())
8454 {
8455 //stat2->setText(QString(" %1 ").arg("Asymptote"));
8456 if (!ERRPROCESS) RunCommand(asymptote_command,true);
8457 else {checkViewerInstance=false;return;}
8458 if (!ERRPROCESS)
8459 {
8460 //stat2->setText(QString(" %1 ").arg("Pdf Latex"));
8461 RunCommand(pdflatex_command,true);
8462 if (ERRPROCESS && !LogExists())
8463 {
8464 QMessageBox::warning( this,tr("Error"),tr("Could not start the command.")+"\n"+pdflatex_command);
8465 checkViewerInstance=false;
8466 return;
8467 }
8468 LoadLog();
8469 if (showoutputview) ViewLog();
8470 if (NoLatexErrors())
8471 {
8472 RunCommand(pdflatex_command,true);
8473 if (ERRPROCESS && !LogExists())
8474 {
8475 QMessageBox::warning( this,tr("Error"),tr("Could not start the command.")+"\n"+pdflatex_command);
8476 checkViewerInstance=false;
8477 return;
8478 }
8479 LoadLog();
8480 if (showoutputview) ViewLog();
8481 if (NoLatexErrors())
8482 {
8483 if (!ERRPROCESS) ViewPDF();
8484 else {checkViewerInstance=false;return;}
8485 }
8486 else {NextError();}
8487 }
8488 else {NextError();}
8489 }
8490 else return;
8491 // if (!ERRPROCESS)
8492 // {
8493 // //stat2->setText(QString(" %1 ").arg("Pdf Latex"));
8494 // RunCommand(pdflatex_command,true);
8495 // if (ERRPROCESS && !LogExists())
8496 // {
8497 // QMessageBox::warning( this,tr("Error"),tr("Could not start the command."));
8498 // checkViewerInstance=false;
8499 // return;
8500 // }
8501 // LoadLog();
8502 // if (showoutputview) ViewLog();
8503 // if (NoLatexErrors())
8504 // {
8505 // if (!ERRPROCESS) ViewPDF();
8506 // else {checkViewerInstance=false;return;}
8507 // }
8508 // else {NextError();}
8509 // }
8510 // else return;
8511 }
8512 else {NextError();}
8513 }break;
8514 case 9:
8515 {
8516 //stat2->setText(QString(" %1 ").arg("LatexMk"));
8517 RunCommand(latexmk_command,true);
8518 if (ERRPROCESS && !LogExists())
8519 {
8520 QMessageBox::warning( this,tr("Error"),tr("Could not start the command.")+"\n"+latexmk_command);
8521 checkViewerInstance=false;
8522 return;
8523 }
8524 LoadLog();
8525 if (showoutputview) ViewLog();
8526 if (NoLatexErrors())
8527 {
8528 if (!ERRPROCESS) ViewPDF();
8529 else {checkViewerInstance=false;return;}
8530 }
8531 else {NextError();}
8532 }break;
8533 case 10:
8534 {
8535 //stat2->setText(QString(" %1 ").arg("Pdf Latex"));
8536 RunCommand(xelatex_command,true);
8537 if (ERRPROCESS && !LogExists())
8538 {
8539 QMessageBox::warning( this,tr("Error"),tr("Could not start the command.")+"\n"+xelatex_command);
8540 checkViewerInstance=false;
8541 return;
8542 }
8543 LoadLog();
8544 if (showoutputview) ViewLog();
8545 if (NoLatexErrors())
8546 {
8547 if (!ERRPROCESS) ViewPDF();
8548 else {checkViewerInstance=false;return;}
8549 }
8550 else {NextError();}
8551 }break;
8552 case 11:
8553 {
8554 //stat2->setText(QString(" %1 ").arg("Pdf Latex"));
8555 RunCommand(lualatex_command,true);
8556 if (ERRPROCESS && !LogExists())
8557 {
8558 QMessageBox::warning( this,tr("Error"),tr("Could not start the command.")+"\n"+lualatex_command);
8559 checkViewerInstance=false;
8560 return;
8561 }
8562 LoadLog();
8563 if (showoutputview) ViewLog();
8564 if (NoLatexErrors())
8565 {
8566 if (!ERRPROCESS) ViewPDF();
8567 else {checkViewerInstance=false;return;}
8568 }
8569 else {NextError();}
8570 }break;
8571 case 12:
8572 {
8573 //stat2->setText(QString(" %1 ").arg("Pdf Latex"));
8574 RunCommand(pdflatex_command,true);
8575 if (ERRPROCESS && !LogExists())
8576 {
8577 QMessageBox::warning( this,tr("Error"),tr("Could not start the command.")+"\n"+pdflatex_command);
8578 checkViewerInstance=false;
8579 return;
8580 }
8581 LoadLog();
8582 if (showoutputview) ViewLog();
8583 if (NoLatexErrors())
8584 {
8585 //stat2->setText(QString(" %1 ").arg("Asymptote"));
8586 if (!ERRPROCESS) RunCommand(bibtex_command,true);
8587 else {checkViewerInstance=false;return;}
8588 if (!ERRPROCESS)
8589 {
8590 //stat2->setText(QString(" %1 ").arg("Pdf Latex"));
8591 RunCommand(pdflatex_command,true);
8592 if (ERRPROCESS && !LogExists())
8593 {
8594 QMessageBox::warning( this,tr("Error"),tr("Could not start the command.")+"\n"+pdflatex_command);
8595 checkViewerInstance=false;
8596 return;
8597 }
8598 LoadLog();
8599 if (showoutputview) ViewLog();
8600 if (NoLatexErrors())
8601 {
8602 RunCommand(pdflatex_command,true);
8603 if (ERRPROCESS && !LogExists())
8604 {
8605 QMessageBox::warning( this,tr("Error"),tr("Could not start the command.")+"\n"+pdflatex_command);
8606 checkViewerInstance=false;
8607 return;
8608 }
8609 LoadLog();
8610 if (showoutputview) ViewLog();
8611 if (NoLatexErrors())
8612 {
8613 if (!ERRPROCESS) ViewPDF();
8614 else {checkViewerInstance=false;return;}
8615 }
8616 else {NextError();}
8617 }
8618 else {NextError();}
8619 }
8620 else return;
8621 }
8622 else {NextError();}
8623 }break;
8624 case 13:
8625 {
8626 //stat2->setText(QString(" %1 ").arg("Pdf Latex"));
8627 RunCommand(latex_command,true);
8628 if (ERRPROCESS && !LogExists())
8629 {
8630 QMessageBox::warning( this,tr("Error"),tr("Could not start the command.")+"\n"+latex_command);
8631 checkViewerInstance=false;
8632 return;
8633 }
8634 LoadLog();
8635 if (showoutputview) ViewLog();
8636 if (NoLatexErrors())
8637 {
8638 //stat2->setText(QString(" %1 ").arg("Asymptote"));
8639 if (!ERRPROCESS) RunCommand(bibtex_command,true);
8640 else {checkViewerInstance=false;return;}
8641 if (!ERRPROCESS)
8642 {
8643 //stat2->setText(QString(" %1 ").arg("Pdf Latex"));
8644 RunCommand(latex_command,true);
8645 if (ERRPROCESS && !LogExists())
8646 {
8647 QMessageBox::warning( this,tr("Error"),tr("Could not start the command.")+"\n"+latex_command);
8648 checkViewerInstance=false;
8649 return;
8650 }
8651 LoadLog();
8652 if (showoutputview) ViewLog();
8653 if (NoLatexErrors())
8654 {
8655 RunCommand(latex_command,true);
8656 if (ERRPROCESS && !LogExists())
8657 {
8658 QMessageBox::warning( this,tr("Error"),tr("Could not start the command.")+"\n"+latex_command);
8659 checkViewerInstance=false;
8660 return;
8661 }
8662 LoadLog();
8663 if (showoutputview) ViewLog();
8664 if (NoLatexErrors())
8665 {
8666 //stat2->setText(QString(" %1 ").arg("Dvips"));
8667 if (!ERRPROCESS) RunCommand(dvips_command,true);
8668 else {checkViewerInstance=false;return;}
8669 //stat2->setText(QString(" %1 ").arg("Ps to Pdf"));
8670 if (!ERRPROCESS) RunCommand(ps2pdf_command,true);
8671 else {checkViewerInstance=false;return;}
8672 if (!ERRPROCESS) ViewPDF();
8673 }
8674 else {NextError();}
8675 }
8676 else {NextError();}
8677 }
8678 else return;
8679 }
8680 else {NextError();}
8681 }break;
8682 case 14:
8683 {
8684 //stat2->setText(QString(" %1 ").arg("Pdf Latex"));
8685 RunCommand(sweave_command,true);
8686 if (!ERRPROCESS) RunCommand(pdflatex_command,true);
8687 if (ERRPROCESS && !LogExists())
8688 {
8689 QMessageBox::warning( this,tr("Error"),tr("Could not start the command.")+"\n"+sweave_command);
8690 checkViewerInstance=false;
8691 return;
8692 }
8693 LoadLog();
8694 if (showoutputview) ViewLog();
8695 if (NoLatexErrors())
8696 {
8697 if (!ERRPROCESS) ViewPDF();
8698 else {checkViewerInstance=false;return;}
8699 }
8700 else {NextError();}
8701 }break;
8702 }
8703 if (NoLatexErrors() && showoutputview) ViewLog();
8704 }
8705 checkViewerInstance=false;
8706 }
8707
Latex()8708 void Texmaker::Latex()
8709 {
8710 //stat2->setText(QString(" %1 ").arg("Latex"));
8711 RunCommand(latex_command,true);
8712 LoadLog();
8713 if (showoutputview) ViewLog();
8714 if (!NoLatexErrors()) NextError();
8715 }
8716
ViewDvi()8717 void Texmaker::ViewDvi()
8718 {
8719 //stat2->setText(QString(" %1 ").arg(tr("View Dvi file")));
8720 RunCommand(viewdvi_command,false);
8721 }
8722
DviToPS()8723 void Texmaker::DviToPS()
8724 {
8725 //stat2->setText(QString(" %1 ").arg("Dvips"));
8726 RunCommand(dvips_command,false);
8727 }
8728
ViewPS()8729 void Texmaker::ViewPS()
8730 {
8731 //stat2->setText(QString(" %1 ").arg(tr("View PS file")));
8732 RunCommand(viewps_command,false);
8733 }
8734
PDFLatex()8735 void Texmaker::PDFLatex()
8736 {
8737 //stat2->setText(QString(" %1 ").arg("Pdf Latex"));
8738 RunCommand(pdflatex_command,true);
8739 LoadLog();
8740 if (showoutputview) ViewLog();
8741 if (!NoLatexErrors()) NextError();
8742 }
8743
ViewPDF()8744 void Texmaker::ViewPDF()
8745 {
8746 //stat2->setText(QString(" %1 ").arg(tr("View Pdf file")));
8747 RunCommand(viewpdf_command,false);
8748 }
8749
MakeBib()8750 void Texmaker::MakeBib()
8751 {
8752 //stat2->setText(QString(" %1 ").arg("Bibtex"));
8753 RunCommand(bibtex_command,false);
8754 }
8755
MakeIndex()8756 void Texmaker::MakeIndex()
8757 {
8758 //stat2->setText(QString(" %1 ").arg("Make index"));
8759 RunCommand(makeindex_command,false);
8760 }
8761
PStoPDF()8762 void Texmaker::PStoPDF()
8763 {
8764 //stat2->setText(QString(" %1 ").arg("Ps -> Pdf"));
8765 RunCommand(ps2pdf_command,false);
8766 }
8767
DVItoPDF()8768 void Texmaker::DVItoPDF()
8769 {
8770 //stat2->setText(QString(" %1 ").arg("Dvi -> Pdf"));
8771 RunCommand(dvipdf_command,false);
8772 }
8773
MetaPost()8774 void Texmaker::MetaPost()
8775 {
8776 //stat2->setText(QString(" %1 ").arg("Mpost"));
8777 QString finame=getName();
8778 QFileInfo fi(finame);
8779 RunCommand(metapost_command+fi.completeBaseName()+"."+fi.suffix(),false);
8780 }
8781
CleanAll()8782 void Texmaker::CleanAll()
8783 {
8784 QString finame,f;
8785 if (singlemode) {finame=getName();}
8786 else {finame=MasterName;}
8787 if ((singlemode && !currentEditorView()) || finame.startsWith("untitled") || finame=="")
8788 {
8789 QMessageBox::warning( this,tr("Error"),tr("Can't detect the file name"));
8790 return;
8791 }
8792 fileSave();
8793 QStringList extension=QString(".log,.aux,.dvi,.lof,.lot,.bit,.idx,.glo,.bbl,.ilg,.toc,.ind,.out,.synctex.gz,.blg,.thm,.pre,.nlg,.nlo,.nls,.bcf,.snm,.nav,.vrb,.listing,.spx,.run.xml").split(",");
8794 if (useoutputdir)
8795 {
8796 QFileInfo fi(outputName(finame,".pdf"));
8797 if(QMessageBox::warning(this, "Texmaker", tr("Make a copy of the %1.pdf/ps document in the \"build\" subdirectory and delete all the others %1.* files?").arg(fi.baseName()),tr("Ok"), tr("Cancel") )==0)
8798 {
8799 QDirIterator iterator(QDir(fi.absolutePath()),QDirIterator::NoIteratorFlags);
8800 while(iterator.hasNext())
8801 {
8802 QString entry(iterator.next());
8803 if (QFileInfo(entry).suffix().toLower()=="pdf" && QFileInfo(entry).baseName()==fi.baseName())
8804 {
8805 copyFile(entry,QFileInfo(finame).absolutePath()+"/"+QFileInfo(entry).completeBaseName()+".pdf");
8806 }
8807 else if (QFileInfo(entry).suffix().toLower()=="ps" && QFileInfo(entry).baseName()==fi.baseName())
8808 {
8809 copyFile(entry,QFileInfo(finame).absolutePath()+"/"+QFileInfo(entry).completeBaseName()+".ps");
8810 }
8811 else if(!QFileInfo(entry).isDir() && QFileInfo(entry).baseName()==fi.baseName())
8812 {
8813 if (QFile::exists(entry))
8814 {
8815 QFile file(entry);
8816 file.open( QIODevice::ReadOnly );
8817 file.remove();
8818 }
8819 }
8820 }
8821 }
8822 }
8823 else
8824 {
8825 QFileInfo fi(finame);
8826 if (QMessageBox::warning(this, "Texmaker", tr("Delete the output files generated by LaTeX ?"),tr("Delete Files"), tr("Cancel") )==0)
8827 {
8828 QDirIterator iterator(QDir(fi.absolutePath()),QDirIterator::NoIteratorFlags);
8829 while(iterator.hasNext())
8830 {
8831 QString entry(iterator.next());
8832 if(!QFileInfo(entry).isDir())
8833 {
8834 if(extension.contains("."+QFileInfo(entry).completeSuffix().toLower()) && QFileInfo(entry).baseName()==fi.baseName())
8835 {
8836 if (QFile::exists(entry))
8837 {
8838 QFile file(entry);
8839 file.open( QIODevice::ReadOnly );
8840 file.remove();
8841 }
8842 }
8843 }
8844 }
8845 }
8846 }
8847 }
8848
8849
AutoCleanAll()8850 void Texmaker::AutoCleanAll()
8851 {
8852 QString finame,f;
8853 if (singlemode) {finame=getName();}
8854 else {finame=MasterName;}
8855 if ((singlemode && !currentEditorView()) || finame.startsWith("untitled") || finame=="")
8856 {
8857 //QMessageBox::warning( this,tr("Error"),tr("Can't detect the file name"));
8858 return;
8859 }
8860 QStringList extension=QString(".log,.aux,.dvi,.lof,.lot,.bit,.idx,.glo,.bbl,.ilg,.toc,.ind,.out,.synctex.gz,.blg,.thm,.pre,.nlg,.nlo,.nls,.bcf,.snm,.nav,.vrb,.listing,.spx,.run.xml").split(",");
8861 if (useoutputdir)
8862 {
8863 QFileInfo fi(outputName(finame,".pdf"));
8864
8865 QDirIterator iterator(QDir(fi.absolutePath()),QDirIterator::NoIteratorFlags);
8866 while(iterator.hasNext())
8867 {
8868 QString entry(iterator.next());
8869 if (QFileInfo(entry).suffix().toLower()=="pdf" && QFileInfo(entry).baseName()==fi.baseName())
8870 {
8871 copyFile(entry,QFileInfo(finame).absolutePath()+"/"+QFileInfo(entry).completeBaseName()+".pdf");
8872 }
8873 else if (QFileInfo(entry).suffix().toLower()=="ps" && QFileInfo(entry).baseName()==fi.baseName())
8874 {
8875 copyFile(entry,QFileInfo(finame).absolutePath()+"/"+QFileInfo(entry).completeBaseName()+".ps");
8876 }
8877 else if(!QFileInfo(entry).isDir() && QFileInfo(entry).baseName()==fi.baseName())
8878 {
8879 if (QFile::exists(entry))
8880 {
8881 QFile file(entry);
8882 file.open( QIODevice::ReadOnly );
8883 file.remove();
8884 }
8885 }
8886 }
8887 }
8888 else
8889 {
8890 QFileInfo fi(finame);
8891 QDirIterator iterator(QDir(fi.absolutePath()),QDirIterator::NoIteratorFlags);
8892 while(iterator.hasNext())
8893 {
8894 QString entry(iterator.next());
8895 if(!QFileInfo(entry).isDir())
8896 {
8897 if(extension.contains("."+QFileInfo(entry).completeSuffix().toLower()) && QFileInfo(entry).baseName()==fi.baseName())
8898 {
8899 if (QFile::exists(entry))
8900 {
8901 QFile file(entry);
8902 file.open( QIODevice::ReadOnly );
8903 file.remove();
8904 }
8905 }
8906 }
8907 }
8908 }
8909 }
8910
8911
Asymptote()8912 void Texmaker::Asymptote()
8913 {
8914 //stat2->setText(QString(" %1 ").arg("Asymptote"));
8915 RunCommand(asymptote_command,false);
8916 }
8917
AsyFile(QString asyfile)8918 void Texmaker::AsyFile(QString asyfile)
8919 {
8920 QString commandline=asymptote_command;
8921 QFileInfo fi(asyfile);
8922 commandline.replace("%","\""+asyfile+"\"");
8923 proc = new QProcess( this );
8924 proc->setWorkingDirectory(fi.absolutePath());
8925 proc->setProperty("command",commandline);
8926
8927 //****
8928 #if defined(Q_OS_MAC)
8929 QProcessEnvironment env = QProcessEnvironment::systemEnvironment();
8930 if (extra_path.isEmpty()) env.insert("PATH", env.value("PATH") + ":/Library/TeX/texbin:/Library/TeX/Distributions/.DefaultTeX/Contents/Programs/texbin:/usr/bin:/usr/sbin:/sbin:/usr/local/bin:/usr/texbin:/sw/bin:");
8931 else
8932 env.insert("PATH", env.value("PATH") + ":/Library/TeX/texbin:/Library/TeX/Distributions/.DefaultTeX/Contents/Programs/texbin:/usr/bin:/usr/sbin:/sbin:/usr/local/bin:/usr/texbin:/sw/bin:"+extra_path);
8933 proc->setProcessEnvironment(env);
8934 #endif
8935 #if defined(Q_OS_WIN32)
8936 QProcessEnvironment env = QProcessEnvironment::systemEnvironment();
8937 if (!extra_path.isEmpty())
8938 {
8939 env.insert("PATH", env.value("PATH") + ";"+extra_path);
8940 proc->setProcessEnvironment(env);
8941 }
8942 #endif
8943 #if defined(Q_OS_UNIX) && !defined(Q_OS_MAC)
8944 QProcessEnvironment env = QProcessEnvironment::systemEnvironment();
8945 if (!extra_path.isEmpty())
8946 {
8947 env.insert("PATH", env.value("PATH") + ":"+extra_path);
8948 proc->setProcessEnvironment(env);
8949 }
8950 #endif
8951 qputenv("PATH", env.value("PATH").toLatin1());
8952 //****
8953 connect(proc, SIGNAL(readyReadStandardError()),this, SLOT(readFromStderr()));
8954 //connect(proc, SIGNAL(readyReadStandardOutput()),this, SLOT(readFromStdoutput()));
8955 connect(proc, SIGNAL(finished(int)),this, SLOT(SlotEndProcess(int)));
8956 OutputTextEdit->clear();
8957 OutputTableWidget->hide();
8958 OutputTextEdit->setMaximumHeight(splitter2->sizes().at(1));
8959 separatorline->hide();
8960 //OutputTextEdit->insertLine(commandline+"\n");
8961 proc->start(commandline);
8962 if (!proc->waitForStarted(1000))
8963 {
8964 ERRPROCESS=true;
8965 OutputTextEdit->insertLine("Error : could not start the command : "+commandline+"\n");
8966 checkViewerInstance=false;
8967 return;
8968 }
8969 else OutputTextEdit->insertLine("Process started\n");
8970 FINPROCESS=false;
8971 QApplication::setOverrideCursor(QCursor(Qt::WaitCursor));
8972 while (!FINPROCESS)
8973 {
8974 qApp->instance()->processEvents(QEventLoop::ExcludeUserInputEvents);
8975 }
8976 QApplication::restoreOverrideCursor();
8977 }
8978
LatexMk()8979 void Texmaker::LatexMk()
8980 {
8981 //stat2->setText(QString(" %1 ").arg("LatexMk"));
8982 RunCommand(latexmk_command,true);
8983 LoadLog();
8984 if (showoutputview) ViewLog();
8985 if (!NoLatexErrors()) NextError();
8986 }
8987
Sweave()8988 void Texmaker::Sweave()
8989 {
8990 //stat2->setText(QString(" %1 ").arg("LatexMk"));
8991 RunCommand(sweave_command,false);
8992 }
8993
Xelatex()8994 void Texmaker::Xelatex()
8995 {
8996 //stat2->setText(QString(" %1 ").arg("Pdf Latex"));
8997 RunCommand(xelatex_command,true);
8998 LoadLog();
8999 if (showoutputview) ViewLog();
9000 if (!NoLatexErrors()) NextError();
9001 }
9002
Lualatex()9003 void Texmaker::Lualatex()
9004 {
9005 //stat2->setText(QString(" %1 ").arg("Pdf Latex"));
9006 RunCommand(lualatex_command,true);
9007 LoadLog();
9008 if (showoutputview) ViewLog();
9009 if (!NoLatexErrors()) NextError();
9010 }
9011
UserTool1()9012 void Texmaker::UserTool1()
9013 {
9014 QStringList commandList=UserToolCommand[0].split("|");
9015 ERRPROCESS=false;
9016 for (int i = 0; i < commandList.size(); ++i)
9017 {
9018 if ((!ERRPROCESS)&&(!commandList.at(i).isEmpty()))
9019 {
9020 RunCommand(commandList.at(i),true);
9021 if ((commandList.at(i)==latex_command) || (commandList.at(i)==pdflatex_command) || (commandList.at(i)==xelatex_command) || (commandList.at(i)==lualatex_command))
9022 {
9023 LoadLog();
9024 if (showoutputview) ViewLog();
9025 if (!NoLatexErrors()) NextError();
9026 }
9027 }
9028 else return;
9029 }
9030 }
9031
UserTool2()9032 void Texmaker::UserTool2()
9033 {
9034 QStringList commandList=UserToolCommand[1].split("|");
9035 ERRPROCESS=false;
9036 for (int i = 0; i < commandList.size(); ++i)
9037 {
9038 if ((!ERRPROCESS)&&(!commandList.at(i).isEmpty()))
9039 {
9040 RunCommand(commandList.at(i),true);
9041 if ((commandList.at(i)==latex_command) || (commandList.at(i)==pdflatex_command) || (commandList.at(i)==xelatex_command) || (commandList.at(i)==lualatex_command))
9042 {
9043 LoadLog();
9044 if (showoutputview) ViewLog();
9045 if (!NoLatexErrors()) NextError();
9046 }
9047 }
9048 else return;
9049 }
9050 }
9051
UserTool3()9052 void Texmaker::UserTool3()
9053 {
9054 QStringList commandList=UserToolCommand[2].split("|");
9055 ERRPROCESS=false;
9056 for (int i = 0; i < commandList.size(); ++i)
9057 {
9058 if ((!ERRPROCESS)&&(!commandList.at(i).isEmpty()))
9059 {
9060 RunCommand(commandList.at(i),true);
9061 if ((commandList.at(i)==latex_command) || (commandList.at(i)==pdflatex_command) || (commandList.at(i)==xelatex_command) || (commandList.at(i)==lualatex_command))
9062 {
9063 LoadLog();
9064 if (showoutputview) ViewLog();
9065 if (!NoLatexErrors()) NextError();
9066 }
9067 }
9068 else return;
9069 }
9070 }
9071
UserTool4()9072 void Texmaker::UserTool4()
9073 {
9074 QStringList commandList=UserToolCommand[3].split("|");
9075 ERRPROCESS=false;
9076 for (int i = 0; i < commandList.size(); ++i)
9077 {
9078 if ((!ERRPROCESS)&&(!commandList.at(i).isEmpty()))
9079 {
9080 RunCommand(commandList.at(i),true);
9081 if ((commandList.at(i)==latex_command) || (commandList.at(i)==pdflatex_command) || (commandList.at(i)==xelatex_command) || (commandList.at(i)==lualatex_command))
9082 {
9083 LoadLog();
9084 if (showoutputview) ViewLog();
9085 if (!NoLatexErrors()) NextError();
9086 }
9087 }
9088 else return;
9089 }
9090 }
9091
UserTool5()9092 void Texmaker::UserTool5()
9093 {
9094 QStringList commandList=UserToolCommand[4].split("|");
9095 ERRPROCESS=false;
9096 for (int i = 0; i < commandList.size(); ++i)
9097 {
9098 if ((!ERRPROCESS)&&(!commandList.at(i).isEmpty()))
9099 {
9100 RunCommand(commandList.at(i),true);
9101 if ((commandList.at(i)==latex_command) || (commandList.at(i)==pdflatex_command) || (commandList.at(i)==xelatex_command) || (commandList.at(i)==lualatex_command))
9102 {
9103 LoadLog();
9104 if (showoutputview) ViewLog();
9105 if (!NoLatexErrors()) NextError();
9106 }
9107 }
9108 else return;
9109 }
9110 }
9111
OpenTerminal()9112 void Texmaker::OpenTerminal()
9113 {
9114 QProcess process;
9115
9116 QString finame;
9117 if (singlemode) {finame=getName();}
9118 else {finame=MasterName;}
9119 if ((singlemode && !currentEditorView()) || finame.startsWith("untitled") || finame=="")
9120 {
9121 finame=QDir::homePath();
9122 }
9123 QFileInfo fi(finame);
9124
9125
9126 const QString pwd = QDir::toNativeSeparators(fi.isDir() ?
9127 fi.absoluteFilePath() :
9128 fi.absolutePath());
9129 process.setWorkingDirectory(pwd);
9130 #if defined(Q_OS_WIN32)
9131 const QString terminalEmulator = QString::fromLocal8Bit(qgetenv("COMSPEC"));
9132 #include <Windows.h>
9133 STARTUPINFO si;
9134 ZeroMemory(&si, sizeof(si));
9135 si.cb = sizeof(si);
9136
9137 PROCESS_INFORMATION pinfo;
9138 ZeroMemory(&pinfo, sizeof(pinfo));
9139
9140 bool success = CreateProcessW(0, (WCHAR *)terminalEmulator.utf16(),
9141 0, 0, FALSE, CREATE_NEW_CONSOLE,
9142 0, pwd.isEmpty() ? 0 : (WCHAR *)pwd.utf16(),
9143 &si, &pinfo);
9144
9145 if (success) {
9146 CloseHandle(pinfo.hThread);
9147 CloseHandle(pinfo.hProcess);
9148 }
9149 #elif defined(Q_OS_MAC)
9150 const QString terminalEmulator = QCoreApplication::applicationDirPath() + "/../Resources/openTerminal.command";
9151 process.startDetached(terminalEmulator,QStringList()<< pwd);
9152 #else
9153 const QString shell = QString::fromLocal8Bit(qgetenv("SHELL"));
9154 if (!process.startDetached("konsole --workdir \""+pwd+"\""))
9155 {
9156 if (!process.startDetached("gnome-terminal --working-directory=\""+pwd+"\"")) process.startDetached("xterm -lc -u8 -e \"cd \'"+pwd+"\' && "+shell+"\"");
9157 }
9158 #endif
9159
9160 }
9161
Export()9162 void Texmaker::Export()
9163 {
9164 if ( !currentEditorView() ) return;
9165 QString finame;
9166 if (singlemode) {finame=getName();}
9167 else {finame=MasterName;}
9168 if ((singlemode && !currentEditorView()) || finame.startsWith("untitled") || finame=="")
9169 {
9170 QMessageBox::warning( this,tr("Error"),tr("Can't detect the file name"));
9171 return;
9172 }
9173 ExportDialog *exportDlg = new ExportDialog(this,finame);
9174 exportDlg->ui.lineEditPath->setText(htlatex_command);
9175 exportDlg->ui.lineEditOptions->setText(htlatex_options);
9176
9177 if (exportDlg->exec())
9178 {
9179 htlatex_command=exportDlg->ui.lineEditPath->text();
9180 htlatex_options=exportDlg->ui.lineEditOptions->text();
9181 }
9182 }
9183
ConvertToUnicode()9184 void Texmaker::ConvertToUnicode()
9185 {
9186 UnicodeDialog *uniDlg = new UnicodeDialog(this);
9187 uniDlg->init(EditorFont,showline,edcolors(),hicolors());
9188 uniDlg->exec();
9189 }
9190
EditUserTool()9191 void Texmaker::EditUserTool()
9192 {
9193 QStringList usualNames, usualCommands;
9194 usualNames << tr("LaTeX") << tr("PdfLaTeX") << tr("dvips") << tr("Dvi Viewer") << tr("PS Viewer") << tr("Dvipdfm") << tr("ps2pdf") << tr("Bibtex") << tr("Makeindex") << tr("Pdf Viewer") << tr("metapost") << tr("ghostscript") << tr("Asymptote") << tr("Latexmk") << tr("R Sweave") << tr("XeLaTex") << tr("LuaLaTex");
9195 usualCommands << latex_command << pdflatex_command << dvips_command << viewdvi_command << viewps_command << dvipdf_command << ps2pdf_command << bibtex_command << makeindex_command<< viewpdf_command << metapost_command << ghostscript_command << asymptote_command << latexmk_command << sweave_command << xelatex_command << lualatex_command;
9196 QAction *Act;
9197 UserToolDialog *utDlg = new UserToolDialog(this,tr("Edit User &Commands"),usualNames, usualCommands);
9198 for ( int i = 0; i <= 4; i++ )
9199 {
9200 utDlg->Name[i]=UserToolName[i];
9201 utDlg->Tool[i]=UserToolCommand[i];
9202 }
9203 utDlg->init();
9204 if ( utDlg->exec() )
9205 {
9206 for ( int i = 0; i <= 4; i++ )
9207 {
9208 UserToolName[i]=utDlg->Name[i];
9209 UserToolCommand[i]=utDlg->Tool[i];
9210 }
9211 user12Menu->clear();
9212 Act = new QAction("1: "+UserToolName[0], this);
9213 Act->setShortcut(Qt::SHIFT+Qt::ALT+Qt::Key_F1);
9214 connect(Act, SIGNAL(triggered()), this, SLOT(UserTool1()));
9215 user12Menu->addAction(Act);
9216 Act = new QAction("2: "+UserToolName[1], this);
9217 Act->setShortcut(Qt::SHIFT+Qt::ALT+Qt::Key_F2);
9218 connect(Act, SIGNAL(triggered()), this, SLOT(UserTool2()));
9219 user12Menu->addAction(Act);
9220 Act = new QAction("3: "+UserToolName[2], this);
9221 Act->setShortcut(Qt::SHIFT+Qt::ALT+Qt::Key_F3);
9222 connect(Act, SIGNAL(triggered()), this, SLOT(UserTool3()));
9223 user12Menu->addAction(Act);
9224 Act = new QAction("4: "+UserToolName[3], this);
9225 Act->setShortcut(Qt::SHIFT+Qt::ALT+Qt::Key_F4);
9226 connect(Act, SIGNAL(triggered()), this, SLOT(UserTool4()));
9227 user12Menu->addAction(Act);
9228 Act = new QAction("5: "+UserToolName[4], this);
9229 Act->setShortcut(Qt::SHIFT+Qt::ALT+Qt::Key_F5);
9230 connect(Act, SIGNAL(triggered()), this, SLOT(UserTool5()));
9231 user12Menu->addAction(Act);
9232 user12Menu->addSeparator();
9233 Act = new QAction(tr("Edit User &Commands"), this);
9234 connect(Act, SIGNAL(triggered()), this, SLOT(EditUserTool()));
9235 user12Menu->addAction(Act);
9236 QStringList list;
9237 list.append(tr("Quick Build"));
9238 list.append("LaTeX");
9239 list.append("Dvi->PS");
9240 list.append("PDFLaTeX");
9241 list.append("BibTeX");
9242 list.append("MakeIndex");
9243 list.append("MPost");
9244 list.append("PS->PDF");
9245 list.append("DVI->PDF");
9246 list.append("Asymptote");
9247 list.append("LatexMk");
9248 list.append("R Sweave");
9249 list.append("XeLaTeX");
9250 list.append("LuaLaTeX");
9251 int runIndex=comboCompil->currentIndex();
9252 for ( int i = 0; i <= 4; i++ ) comboCompil->setItemText(14+i,QString::number(i+1)+": "+UserToolName[i]);
9253 comboCompil->setCurrentIndex(runIndex);
9254 }
9255 }
9256
doCompile()9257 void Texmaker::doCompile()
9258 {
9259 switch (comboCompil->currentIndex())
9260 {
9261 case 0:
9262 {
9263 QuickBuild();
9264 }break;
9265 case 1:
9266 {
9267 Latex();
9268 }break;
9269 case 2:
9270 {
9271 DviToPS();
9272 }break;
9273 case 3:
9274 {
9275 PDFLatex();
9276 }break;
9277 case 4:
9278 {
9279 MakeBib();
9280 }break;
9281 case 5:
9282 {
9283 MakeIndex();
9284 }break;
9285 case 6:
9286 {
9287 MetaPost();
9288 }break;
9289 case 7:
9290 {
9291 PStoPDF();
9292 }break;
9293 case 8:
9294 {
9295 DVItoPDF();
9296 }break;
9297 case 9:
9298 {
9299 Asymptote();
9300 }break;
9301 case 10:
9302 {
9303 LatexMk();
9304 }break;
9305 case 11:
9306 {
9307 Sweave();
9308 }break;
9309 case 12:
9310 {
9311 Xelatex();
9312 }break;
9313 case 13:
9314 {
9315 Lualatex();
9316 }break;
9317 case 14:
9318 {
9319 UserTool1();
9320 }break;
9321 case 15:
9322 {
9323 UserTool2();
9324 }break;
9325 case 16:
9326 {
9327 UserTool3();
9328 }break;
9329 case 17:
9330 {
9331 UserTool4();
9332 }break;
9333 case 18:
9334 {
9335 UserTool5();
9336 }break;
9337 }
9338 }
9339
doView()9340 void Texmaker::doView()
9341 {
9342 switch (comboView->currentIndex())
9343 {
9344 case 0:
9345 {
9346 ViewDvi();
9347 }break;
9348 case 1:
9349 {
9350 ViewPS();
9351 }break;
9352 case 2:
9353 {
9354 ViewPDF();
9355 }break;
9356 }
9357 }
9358
jumpToPdfline(int line)9359 void Texmaker::jumpToPdfline(int line)
9360 {
9361 if (!builtinpdfview) return;
9362 QString finame;
9363 if (singlemode) {finame=getName();}
9364 else {finame=MasterName;}
9365 if ((singlemode && !currentEditorView()) || finame.startsWith("untitled") || finame=="")
9366 {
9367 QMessageBox::warning( this,tr("Error"),tr("Can't detect the file name"));
9368 return;
9369 }
9370 fileSave();
9371 QFileInfo fi(finame);
9372 if (!fi.exists()) return;
9373 QString basename=fi.completeBaseName();
9374 if (embedinternalpdf)
9375 {
9376 if (pdfviewerWidget)
9377 {
9378 if (pdfviewerWidget->pdf_file!=outputName(finame,".pdf")) pdfviewerWidget->openFile(outputName(finame,".pdf"),viewpdf_command,ghostscript_command);
9379 StackedViewers->setCurrentWidget(pdfviewerWidget);
9380 //pdfviewerWidget->raise();
9381 pdfviewerWidget->show();
9382 if ( (pdflatex_command.contains("synctex=1")) || (latex_command.contains("synctex=1")) || (xelatex_command.contains("synctex=1"))) pdfviewerWidget->jumpToPdfFromSource(getName(),line,1);
9383 pdfviewerWidget->getFocus();
9384 }
9385 else
9386 {
9387 // pdfviewerWidget=new PdfViewer(outputName(finame,".pdf"),viewpdf_command, this);
9388 pdfviewerWidget=new PdfViewerWidget(outputName(finame,".pdf"),viewpdf_command,ghostscript_command,lp_options,QKeySequence(keyToggleFocus),pdfCheckerLang,lastScale,StackedViewers);
9389 pdfviewerWidget->centralToolBarBis->setMinimumHeight(centralToolBarBis->height());
9390 pdfviewerWidget->centralToolBarBis->setMaximumHeight(centralToolBarBis->height());
9391 connect(pdfviewerWidget, SIGNAL(openDocAtLine(const QString&, int, bool)), this, SLOT(fileOpenAndGoto(const QString&, int, bool)));
9392 connect(pdfviewerWidget, SIGNAL(sendFocusToEditor()), this, SLOT(getFocusToEditor()));
9393 connect(pdfviewerWidget, SIGNAL(sendPaperSize(const QString&)), this, SLOT(setPrintPaperSize(const QString&)));
9394 StackedViewers->addWidget(pdfviewerWidget);
9395 StackedViewers->setCurrentWidget(pdfviewerWidget);
9396 //pdfviewerWidget->raise();
9397 pdfviewerWidget->show();
9398 pdfviewerWidget->openFile(outputName(finame,".pdf"),viewpdf_command,ghostscript_command);
9399 if ( (pdflatex_command.contains("synctex=1")) || (latex_command.contains("synctex=1")) || (xelatex_command.contains("synctex=1"))) pdfviewerWidget->jumpToPdfFromSource(getName(),line,1);
9400 pdfviewerWidget->getFocus();
9401 }
9402 }
9403 else
9404 {
9405 if (pdfviewerWindow)
9406 {
9407 if (pdfviewerWindow->pdf_file!=outputName(finame,".pdf")) pdfviewerWindow->openFile(outputName(finame,".pdf"),viewpdf_command,ghostscript_command);
9408 pdfviewerWindow->raise();
9409 pdfviewerWindow->show();
9410 qApp->setActiveWindow(pdfviewerWindow);
9411 pdfviewerWindow->setFocus();
9412 if ( (pdflatex_command.contains("synctex=1")) || (latex_command.contains("synctex=1")) || (xelatex_command.contains("synctex=1")) ) pdfviewerWindow->jumpToPdfFromSource(getName(),line,1);
9413 }
9414 else
9415 {
9416 // pdfviewerWindow=new PdfViewer(outputName(finame,".pdf"),viewpdf_command, this);
9417 pdfviewerWindow=new PdfViewer(outputName(finame,".pdf"),viewpdf_command,ghostscript_command,lp_options,QKeySequence(keyToggleFocus),pdfCheckerLang,lastScale,0);
9418 connect(pdfviewerWindow, SIGNAL(openDocAtLine(const QString&, int, bool)), this, SLOT(fileOpenAndGoto(const QString&, int, bool)));
9419 connect(pdfviewerWindow, SIGNAL(sendFocusToEditor()), this, SLOT(getFocusToEditor()));
9420 connect(pdfviewerWindow, SIGNAL(sendPaperSize(const QString&)), this, SLOT(setPrintPaperSize(const QString&)));
9421 pdfviewerWindow->raise();
9422 pdfviewerWindow->show();
9423 if ( (pdflatex_command.contains("synctex=1")) || (latex_command.contains("synctex=1")) || (xelatex_command.contains("synctex=1"))) pdfviewerWindow->jumpToPdfFromSource(getName(),line,1);
9424 }
9425 }
9426 }
9427
9428
9429 //////////////// MESSAGES - LOG FILE///////////////////////
LogExists()9430 bool Texmaker::LogExists()
9431 {
9432 QString finame;
9433 if (singlemode) {finame=getName();}
9434 else {finame=MasterName;}
9435 if ((singlemode && !currentEditorView()) ||finame.startsWith("untitled") || finame=="")
9436 {
9437 return false;
9438 }
9439 QString logname=outputName(finame,".log");
9440 // QFileInfo fi(finame);
9441 // QString name=fi.absoluteFilePath();
9442 // QString ext=fi.suffix();
9443 // QString basename=name.left(name.length()-ext.length()-1);
9444 // QString logname=basename+".log";
9445 QFileInfo fic(logname);
9446 if (fic.exists() && fic.isReadable()) return true;
9447 else return false;
9448 }
9449
LoadLog()9450 void Texmaker::LoadLog()
9451 {
9452 OutputTextEdit->clear();
9453 logpresent=false;
9454 QString finame;
9455 if (singlemode) {finame=getName();}
9456 else {finame=MasterName;}
9457 if ((singlemode && !currentEditorView()) ||finame.startsWith("untitled") || finame=="")
9458 {
9459 QMessageBox::warning( this,tr("Error"),tr("Could not start the command.")+"\n view log ");
9460 ERRPROCESS=true;
9461 return;
9462 }
9463 QString logname=outputName(finame,".log");
9464 // QFileInfo fi(finame);
9465 // QString name=fi.absoluteFilePath();
9466 // QString ext=fi.suffix();
9467 // QString basename=name.left(name.length()-ext.length()-1);
9468 // QString logname=basename+".log";
9469 QString line;
9470 QFileInfo fic(logname);
9471 QTextCodec* codec = QTextCodec::codecForName(input_encoding.toLatin1());
9472 if(!codec) codec = QTextCodec::codecForLocale();
9473 int li=0;
9474 if (fic.exists() && fic.isReadable() )
9475 {
9476 OutputTextEdit->insertLine("LOG FILE :");
9477 QFile f(logname);
9478 if ( f.open(QIODevice::ReadOnly))
9479 {
9480 QTextStream t( &f );
9481 t.setCodec(codec);
9482 // OutputTextEdit->setPlainText( t.readAll() );
9483 while ( (!t.atEnd()) && (li<100000) )
9484 {
9485 li++;
9486 line=t.readLine();
9487 line=line.simplified();
9488 if (!line.isEmpty()) OutputTextEdit->insertLine(line);
9489 }
9490 }
9491 f.close();
9492 LatexError();
9493 logpresent=true;
9494 }
9495 else {QMessageBox::warning( this,tr("Error"),tr("Log File not found !"));}
9496 }
ViewLog()9497 void Texmaker::ViewLog()
9498 {
9499 LoadLog();
9500 if (!showoutputview) ShowOutputView(true);
9501 }
9502
ClickedOnOutput(int l)9503 void Texmaker::ClickedOnOutput(int l)
9504 {
9505 if ( !currentEditorView() ) return;
9506 currentEditorView()->editor->gotoLine(l);
9507 }
9508
ClickedOnLogLine(QTableWidgetItem * item)9509 void Texmaker::ClickedOnLogLine(QTableWidgetItem *item)
9510 {
9511 if ( !currentEditorView() ) return;
9512 if ( !item ) return;
9513 QString content=item->text();
9514 int row=OutputTableWidget->row(item);
9515 int col=OutputTableWidget->column(item);
9516 if (col!=3) content=OutputTableWidget->item(row,3)->text();
9517 QString file=OutputTableWidget->item(row,1)->text();
9518
9519 int Start, End;
9520 bool ok;
9521 QString s;
9522 QString line="";
9523 //// l. ///
9524 s = content;
9525 Start=End=0;
9526 Start=s.indexOf(QRegExp("l.[0-9]"), End);
9527 if (Start!=-1)
9528 {
9529 Start=Start+2;
9530 s=s.mid(Start,s.length());
9531
9532 if (End!=-1)
9533 line=s.mid(0,End);
9534 else
9535 line=s.mid(0,s.length());
9536 };
9537 //// line ///
9538 s = content;
9539 Start=End=0;
9540 Start=s.indexOf(QRegExp("line [0-9]"), End);
9541 if (Start!=-1)
9542 {
9543 Start=Start+5;
9544 s=s.mid(Start,s.length());
9545 End=s.indexOf(QRegExp("[ a-zA-Z.\\-]"),0);
9546 if (End!=-1)
9547 line=s.mid(0,End);
9548 else
9549 line=s.mid(0,s.length());
9550 };
9551 //// lines ///
9552 s = content;
9553 Start=End=0;
9554 Start=s.indexOf(QRegExp("lines [0-9]"), End);
9555 if (Start!=-1)
9556 {
9557 Start=Start+6;
9558 s=s.mid(Start,s.length());
9559 End=s.indexOf(QRegExp("[ a-zA-Z.\\-]"),0);
9560 if (End!=-1)
9561 line=s.mid(0,End);
9562 else
9563 line=s.mid(0,s.length());
9564 };
9565 int l=line.toInt(&ok,10)-1;
9566 if (ok)
9567 {
9568 if (file.isEmpty()) currentEditorView()->editor->gotoLine(l);
9569 else
9570 {
9571 QFileInfo fi(file);
9572 if (fi.exists() && fi.isReadable() ) fileOpenAndGoto(fi.absoluteFilePath(),l+1,true);
9573 else
9574 {
9575 QFileInfo fic(getName());
9576 file=fic.absolutePath()+"/"+file;
9577 QFileInfo ffi(file);
9578 if (ffi.exists() && ffi.isReadable() ) fileOpenAndGoto(file,l+1,true);
9579 }
9580 }
9581 }
9582 QString ll=item->data(Qt::UserRole).toString();
9583 int logline=ll.toInt(&ok,10)-1;
9584 OutputTextEdit->setCursorPosition(logline , 0);
9585 }
9586
9587 ////////////////////////// ERRORS /////////////////////////////
LatexError()9588 void Texmaker::LatexError()
9589 {
9590 errorFileList.clear();
9591 errorTypeList.clear();
9592 errorLineList.clear();
9593 errorMessageList.clear();
9594 errorLogList.clear();
9595 onlyErrorList.clear();
9596 errorIndex=-1;
9597
9598 QString mot,suivant,lettre,expression,warning,latexerror,badbox,name;
9599 QStringList pile,filestack;
9600 filestack.clear();
9601 pile.clear();
9602
9603 int j;
9604
9605 int ligne=0;
9606 int par=1;
9607 int errorpar=1;
9608
9609 QRegExp rxWarning1("Warning: (.*) on.*line *(\\d+)");
9610 QRegExp rxWarning2("Warning: (.*)");
9611 QRegExp rxLatexError("(! )*(LaTeX Error:)* *(.*)\\.l\\.(\\d+) *(.*)");
9612 QRegExp rxLineError("l\\.(\\d+)");
9613 QRegExp rxBadBox("at (line|lines) ([0-9]+)");
9614 QRegExp rxFile("(.*(\\.tex|\\.sty|\\.cls))");
9615
9616
9617 QTextBlock tb = OutputTextEdit->document()->begin();
9618 while (tb.isValid())
9619 {
9620 errorpar=par;
9621 expression=tb.text();
9622 j=0;
9623 pile.clear();
9624 while (j<expression.length())
9625 {
9626 lettre=expression.mid(j,1);
9627 if (lettre=="(" || lettre==")")
9628 {
9629 pile.prepend(lettre);
9630 j+=1;
9631 }
9632 else
9633 {
9634 mot="";
9635 while (j<expression.length() && (expression.mid(j,1)!="(" && expression.mid(j,1)!=")"))
9636 {
9637 mot+=expression.mid(j,1);
9638 j+=1;
9639 }
9640 pile.prepend(mot);
9641 }
9642 }
9643 while (pile.count()>0)
9644 {
9645 mot=pile.last();
9646 pile.removeLast();
9647 if (mot=="(" && pile.count()>0)
9648 {
9649 suivant=pile.last();
9650 pile.removeLast();
9651 if (rxFile.indexIn(suivant) != -1) name=rxFile.cap(1);
9652 else name="";
9653 if (name.startsWith("./")) name.remove("./");
9654 filestack.append(name);
9655 }
9656 else if (mot==")" && filestack.count()>0) filestack.removeLast();
9657 }
9658 if (expression.contains("Warning"))
9659 {
9660 warning=expression.trimmed();
9661 while (tb.isValid() && !expression.contains(QRegExp("\\.$")))
9662 {
9663 par++;
9664 tb=tb.next();
9665 if (tb.isValid())
9666 {
9667 expression=tb.text();
9668 warning+=expression.trimmed();
9669 }
9670 }
9671
9672 if ( rxWarning1.indexIn(warning) != -1 )
9673 {
9674 if (!filestack.isEmpty()) errorFileList.append(filestack.last());
9675 else errorFileList.append("");
9676 errorTypeList.append("Warning");
9677 errorLineList.append(rxWarning1.cap(2));
9678 errorMessageList.append(rxWarning1.cap(1).replace("*",""));
9679 errorLogList.append(QString::number(errorpar));
9680 }
9681 else if ( rxWarning2.indexIn(warning) != -1 )
9682 {
9683 if (!filestack.isEmpty()) errorFileList.append(filestack.last());
9684 else errorFileList.append("");
9685 errorTypeList.append("Warning");
9686 errorLineList.append("1");
9687 errorMessageList.append(rxWarning2.cap(1).replace("*",""));
9688 errorLogList.append(QString::number(errorpar));
9689 }
9690 else
9691 {
9692 if (!filestack.isEmpty()) errorFileList.append(filestack.last());
9693 else errorFileList.append("");
9694 errorTypeList.append("Warning");
9695 errorLineList.append("1");
9696 errorMessageList.append(warning.replace("*",""));
9697 errorLogList.append(QString::number(errorpar));
9698 }
9699 errorpar=par;
9700 }
9701 // else if (expression.contains(QRegExp("^!")))
9702 else if (expression.contains(QRegExp("^! (.*)")))
9703 {
9704 latexerror=expression.trimmed();
9705 while (tb.isValid() && !expression.contains(rxLineError))
9706 {
9707 par++;
9708 tb=tb.next();
9709 if (tb.isValid())
9710 {
9711 expression=tb.text();
9712 latexerror+=expression.trimmed();
9713 }
9714 }
9715 // if ( rxLatexError.indexIn(latexerror) != -1 )
9716 // {
9717 // errorFileList.append(filestack.last());
9718 // errorTypeList.append("Error");
9719 // errorLineList.append(rxLatexError.cap(1));
9720 // errorMessageList.append(rxLatexError.cap(3)+" :"+rxLatexError.cap(5));
9721 // }
9722 if ( rxLineError.indexIn(latexerror) != -1 )
9723 {
9724 if (!filestack.isEmpty()) errorFileList.append(filestack.last());
9725 else errorFileList.append("");
9726 errorTypeList.append("Error");
9727 errorLineList.append(rxLineError.cap(1));
9728 errorMessageList.append(latexerror.remove(rxLineError).replace("*",""));
9729 errorLogList.append(QString::number(errorpar));
9730 }
9731 else
9732 {
9733 if (!filestack.isEmpty()) errorFileList.append(filestack.last());
9734 else errorFileList.append("");
9735 errorTypeList.append("Error");
9736 errorLineList.append("1");
9737 errorMessageList.append(latexerror.replace("*",""));
9738 errorLogList.append(QString::number(errorpar));
9739 }
9740 errorpar=par;
9741 }
9742 else if (expression.contains(QRegExp("^(Over|Under)(full \\\\[hv]box .*)")))
9743 {
9744 badbox=expression.trimmed();
9745 /* while (tb.isValid() && !expression.contains(QRegExp("(.*) at line")))
9746 {
9747 par++;
9748 tb=tb.next();
9749 if (tb.isValid())
9750 {
9751 expression=tb.text();
9752 badbox+=expression.trimmed();
9753 }
9754 }*/
9755 if ( rxBadBox.indexIn(badbox) != -1 )
9756 {
9757 if (!filestack.isEmpty()) errorFileList.append(filestack.last());
9758 else errorFileList.append("");
9759 errorTypeList.append("Badbox");
9760 errorLineList.append(rxBadBox.cap(2));
9761 errorMessageList.append(badbox.replace("*",""));
9762 errorLogList.append(QString::number(errorpar));
9763 }
9764 else
9765 {
9766 if (!filestack.isEmpty()) errorFileList.append(filestack.last());
9767 else errorFileList.append("");
9768 errorTypeList.append("Badbox");
9769 errorLineList.append("1");
9770 errorMessageList.append(badbox.replace("*",""));
9771 errorLogList.append(QString::number(errorpar));
9772 }
9773 errorpar=par;
9774 }
9775 if (tb.isValid())
9776 {
9777 par++;
9778 tb = tb.next();
9779 }
9780 }
9781 DisplayLatexError();
9782 }
9783
DisplayLatexError()9784 void Texmaker::DisplayLatexError()
9785 {
9786 OutputTableWidget->clearContents();
9787 QFontMetrics fm(qApp->font());
9788 int rowheight=fm.lineSpacing()+4;
9789 int maxwidth=0;
9790 int maxwidthline=0;
9791 int row=0;
9792 if (errorFileList.count()>0)
9793 {
9794 OutputTableWidget->setRowCount(errorFileList.count());
9795 for ( int i = 0; i <errorFileList.count(); i++ )
9796 {
9797 if (errorTypeList.at(i)=="Error")
9798 {
9799 QTableWidgetItem *ItemFile = new QTableWidgetItem(errorFileList.at(i));
9800 ItemFile->setData(Qt::UserRole,errorLogList.at(i));
9801 ItemFile->setForeground(QBrush(QColor(Qt::red)));
9802 ItemFile->setFlags(Qt::ItemIsSelectable | Qt::ItemIsEnabled);
9803 OutputTableWidget->setItem(row,1, ItemFile);
9804 QTableWidgetItem *ItemType = new QTableWidgetItem(errorTypeList.at(i));
9805 ItemType->setData(Qt::UserRole,errorLogList.at(i));
9806 ItemType->setForeground(QBrush(QColor(Qt::red)));
9807 ItemType->setFlags(Qt::ItemIsSelectable | Qt::ItemIsEnabled);
9808 OutputTableWidget->setItem(row,2, ItemType);
9809 QTableWidgetItem *ItemLine = new QTableWidgetItem("line "+errorLineList.at(i));
9810 if (fm.width("line "+errorLineList.at(i))>maxwidthline) maxwidthline=fm.width("line "+errorLineList.at(i));
9811 ItemLine->setData(Qt::UserRole,errorLogList.at(i));
9812 ItemLine->setForeground(QBrush(QColor(Qt::red)));
9813 ItemLine->setFlags(Qt::ItemIsSelectable | Qt::ItemIsEnabled);
9814 ItemLine->setToolTip(tr("Click to jump to the line"));
9815 OutputTableWidget->setItem(row,3, ItemLine);
9816 QTableWidgetItem *ItemMessage = new QTableWidgetItem(errorMessageList.at(i));
9817 if (fm.width(errorMessageList.at(i))>maxwidth) maxwidth=fm.width(errorMessageList.at(i));
9818 ItemMessage->setData(Qt::UserRole,errorLogList.at(i));
9819 ItemMessage->setFlags(Qt::ItemIsSelectable | Qt::ItemIsEnabled);
9820 ItemMessage->setForeground(QBrush(QColor(Qt::red)));
9821 OutputTableWidget->setItem(row,4, ItemMessage);
9822
9823 onlyErrorList.append(i);
9824 row++;
9825 }
9826 }
9827 for ( int i = 0; i <errorFileList.count(); i++ )
9828 {
9829 if (errorTypeList.at(i)!="Error")
9830 {
9831 QTableWidgetItem *ItemFile = new QTableWidgetItem(errorFileList.at(i));
9832 ItemFile->setData(Qt::UserRole,errorLogList.at(i));
9833 ItemFile->setForeground(QBrush(QColor(Qt::blue)));
9834 ItemFile->setFlags(Qt::ItemIsSelectable | Qt::ItemIsEnabled);
9835 OutputTableWidget->setItem(row,1, ItemFile);
9836 QTableWidgetItem *ItemType = new QTableWidgetItem(errorTypeList.at(i));
9837 ItemType->setData(Qt::UserRole,errorLogList.at(i));
9838 ItemType->setFlags(Qt::ItemIsSelectable | Qt::ItemIsEnabled);
9839 ItemType->setForeground(QBrush(QColor(Qt::blue)));
9840 OutputTableWidget->setItem(row,2, ItemType);
9841 QTableWidgetItem *ItemLine = new QTableWidgetItem("line "+errorLineList.at(i));
9842 if (fm.width("line "+errorLineList.at(i))>maxwidthline) maxwidthline=fm.width("line "+errorLineList.at(i));
9843 ItemLine->setData(Qt::UserRole,errorLogList.at(i));
9844 ItemLine->setForeground(QBrush(QColor(Qt::blue)));
9845 ItemLine->setFlags(Qt::ItemIsSelectable | Qt::ItemIsEnabled);
9846 ItemLine->setToolTip(tr("Click to jump to the line"));
9847 OutputTableWidget->setItem(row,3, ItemLine);
9848 QTableWidgetItem *ItemMessage = new QTableWidgetItem(errorMessageList.at(i));
9849 if (fm.width(errorMessageList.at(i))>maxwidth) maxwidth=fm.width(errorMessageList.at(i));
9850 ItemMessage->setData(Qt::UserRole,errorLogList.at(i));
9851 ItemMessage->setFlags(Qt::ItemIsSelectable | Qt::ItemIsEnabled);
9852 ItemMessage->setForeground(QBrush(QColor(Qt::blue)));
9853 OutputTableWidget->setItem(row,4, ItemMessage);
9854 row++;
9855 }
9856 }
9857 //OutputTableWidget->horizontalHeader()->setResizeMode(QHeaderView::Fixed);
9858 OutputTableWidget->horizontalHeader()->resizeSection(3,maxwidthline+10);
9859 //OutputTableWidget->horizontalHeader()->resizeSection(4,maxwidth);
9860 //OutputTableWidget->setColumnWidth(4,maxwidth);
9861 //OutputTableWidget->setColumnWidth(3,maxwidthline);
9862 for ( int i = 0; i<OutputTableWidget->rowCount(); ++i )
9863 {
9864 OutputTableWidget->setRowHeight(i,rowheight);
9865 }
9866 OutputTableWidget->resizeColumnsToContents();
9867 // OutputTableWidget->resizeRowsToContents();
9868 }
9869 else
9870 {
9871 OutputTableWidget->setRowCount(1);
9872 OutputTableWidget->setRowHeight(0,rowheight);
9873 OutputTableWidget->clearContents();
9874 }
9875 OutputTextEdit->setMaximumHeight(5*(fm.lineSpacing()+4));
9876 OutputTableWidget->show();
9877 separatorline->show();
9878 OutputTextEdit->setCursorPosition(0 , 0);
9879 }
9880
NoLatexErrors()9881 bool Texmaker::NoLatexErrors()
9882 {
9883 return onlyErrorList.isEmpty();
9884 }
9885
NextError()9886 void Texmaker::NextError()
9887 {
9888 int line=0;
9889 QTableWidgetItem *Item;
9890 if (!logpresent) {LoadLog();}
9891 if (!showoutputview) ShowOutputView(true);
9892 //ViewLog();
9893 if (logpresent && !onlyErrorList.isEmpty())
9894 {
9895 if (errorIndex<onlyErrorList.size()-1) errorIndex=errorIndex+1;
9896 if (errorIndex<0) errorIndex=0;
9897 if (errorIndex>=onlyErrorList.count()) errorIndex=onlyErrorList.count()-1;
9898 if (singlemode)// && onlyErrorList.at(errorIndex)!=0)
9899 {
9900 line=errorLineList.at(onlyErrorList.at(errorIndex)).toInt();
9901 for ( int i = 0; i <errorFileList.count(); i++ )
9902 {
9903 Item = new QTableWidgetItem(" ");
9904 OutputTableWidget->setItem(i,0, Item);
9905 }
9906 Item = new QTableWidgetItem(">");
9907 OutputTableWidget->setItem(errorIndex,0, Item);
9908 OutputTableWidget->scrollToItem(Item,QAbstractItemView::PositionAtCenter);
9909 if (line>1) ClickedOnOutput(line-1);
9910 int logline=errorLogList.at(onlyErrorList.at(errorIndex)).toInt()-1;
9911 OutputTextEdit->setCursorPosition(logline , 0);
9912 }
9913 }
9914 if (logpresent && onlyErrorList.isEmpty())
9915 {
9916 QMessageBox::information( this,"Texmaker",tr("No LaTeX errors detected !"));
9917 OutputTextEdit->setCursorPosition(0 , 0);
9918 }
9919 }
9920
PreviousError()9921 void Texmaker::PreviousError()
9922 {
9923 int line=0;
9924 QTableWidgetItem *Item;
9925 if (!logpresent) {LoadLog();}
9926 if (!showoutputview) ShowOutputView(true);
9927 //ViewLog();
9928 if (logpresent && !onlyErrorList.isEmpty())
9929 {
9930 if (errorIndex>0) errorIndex=errorIndex-1;
9931 if (errorIndex<0) errorIndex=0;
9932 if (errorIndex>=onlyErrorList.count()) errorIndex=onlyErrorList.count()-1;
9933 if (singlemode)// && onlyErrorList.at(errorIndex)!=0)
9934 {
9935 line=errorLineList.at(onlyErrorList.at(errorIndex)).toInt();
9936 for ( int i = 0; i <errorFileList.count(); i++ )
9937 {
9938 Item = new QTableWidgetItem(" ");
9939 OutputTableWidget->setItem(i,0, Item);
9940 }
9941 Item = new QTableWidgetItem(">");
9942 OutputTableWidget->setItem(errorIndex,0, Item);
9943 OutputTableWidget->scrollToItem(Item,QAbstractItemView::PositionAtCenter);
9944 if (line>1) ClickedOnOutput(line-1);
9945 int logline=errorLogList.at(onlyErrorList.at(errorIndex)).toInt()-1;
9946 OutputTextEdit->setCursorPosition(logline , 0);
9947 }
9948 }
9949 if (logpresent && onlyErrorList.isEmpty())
9950 {
9951 QMessageBox::information( this,"Texmaker",tr("No LaTeX errors detected !"));
9952 OutputTextEdit->setCursorPosition(0 , 0);
9953 }
9954 }
9955
9956 //////////////// HELP /////////////////
LatexHelp()9957 void Texmaker::LatexHelp()
9958 {
9959 #if defined(Q_OS_UNIX) && !defined(Q_OS_MAC)
9960
9961 #ifdef USB_VERSION
9962 QString docfile=QCoreApplication::applicationDirPath() + "/latexhelp.html";
9963 #else
9964 QString docfile=PREFIX"/share/texmaker/latexhelp.html";
9965 #endif
9966
9967 #endif
9968 #if defined(Q_OS_MAC)
9969 QString docfile=QCoreApplication::applicationDirPath() + "/../Resources/latexhelp.html";
9970 #endif
9971 #if defined(Q_OS_WIN32)
9972 QString docfile=QCoreApplication::applicationDirPath() + "/latexhelp.html";
9973 #endif
9974 QFileInfo fic(docfile);
9975 if (fic.exists() && fic.isReadable() )
9976 {
9977 #ifdef INTERNAL_BROWSER
9978 if (browserWindow)
9979 {
9980 browserWindow->close();
9981 }
9982 browserWindow=new Browser("file:///"+docfile,true, 0);
9983 browserWindow->raise();
9984 browserWindow->show();
9985 #else
9986 QDesktopServices::openUrl("file:///"+docfile);
9987 #endif
9988 }
9989 else { QMessageBox::warning( this,tr("Error"),tr("File not found"));}
9990 }
9991
UserManualHelp()9992 void Texmaker::UserManualHelp()
9993 {
9994 QString locale = QString(QLocale::system().name()).left(2);
9995 if ( locale.length() < 2 || (locale!="fr" /*&& locale!="hu" && locale!="ru"*/) ) locale = "en";
9996 #if defined(Q_OS_UNIX) && !defined(Q_OS_MAC)
9997
9998 #ifdef USB_VERSION
9999 QString docfile=QCoreApplication::applicationDirPath() + "/usermanual_"+locale+".html";
10000 #else
10001 QString docfile=PREFIX"/share/texmaker/usermanual_"+locale+".html";
10002 #endif
10003
10004 #endif
10005 #if defined(Q_OS_MAC)
10006 QString docfile=QCoreApplication::applicationDirPath() + "/../Resources/usermanual_"+locale+".html";
10007 #endif
10008 #if defined(Q_OS_WIN32)
10009 QString docfile=QCoreApplication::applicationDirPath() + "/usermanual_"+locale+".html";
10010 #endif
10011 QFileInfo fic(docfile);
10012 if (fic.exists() && fic.isReadable() )
10013 {
10014 #ifdef INTERNAL_BROWSER
10015 if (browserWindow)
10016 {
10017 browserWindow->close();
10018 }
10019 browserWindow=new Browser("file:///"+docfile,true, 0);
10020 browserWindow->raise();
10021 browserWindow->show();
10022 #else
10023 QDesktopServices::openUrl("file:///"+docfile);
10024 #endif
10025 }
10026 else { QMessageBox::warning( this,tr("Error"),tr("File not found"));}
10027 }
10028
TexDocHelp()10029 void Texmaker::TexDocHelp()
10030 {
10031 QString text="";
10032 QString item="";
10033 TexdocDialog *texdocDlg = new TexdocDialog(this);
10034 texdocDlg->ui.lineEditCommand->setText(texdoc_command);
10035 if (currentEditorView())
10036 {
10037 if (currentEditorView()->editor->textCursor().hasSelection()) item=currentEditorView()->editor->textCursor().selectedText();
10038 }
10039 texdocDlg->ui.lineEdit->setText(item);
10040 if (texdocDlg->exec())
10041 {
10042 text =texdocDlg->ui.lineEdit->text();
10043 texdoc_command=texdocDlg->ui.lineEditCommand->text();
10044 }
10045 if (!text.isEmpty())
10046 {
10047 QProcess* texdocprocess=new QProcess();
10048 if (!texdocprocess->startDetached(QString("texdoc ")+text)) QMessageBox::warning( this,tr("Error"),tr("Could not start the command.")+"\n texdoc");
10049 }
10050 }
10051
HelpAbout()10052 void Texmaker::HelpAbout()
10053 {
10054 AboutDialog *abDlg = new AboutDialog(this);
10055 abDlg->exec();
10056 }
10057
CheckVersion()10058 void Texmaker::CheckVersion()
10059 {
10060 VersionDialog *verDlg = new VersionDialog(this);
10061 verDlg->exec();
10062 }
10063
10064
10065
10066 // void Texmaker::Docufrlatex()
10067 // {
10068 // QDesktopServices::openUrl(QUrl("http://www.xm1math.net/doculatex/index.html"));
10069 // }
10070
Doculatex()10071 void Texmaker::Doculatex()
10072 {
10073 QDesktopServices::openUrl(QUrl("http://en.wikibooks.org/wiki/LaTeX"));
10074 }
10075
10076 ////////////// OPTIONS //////////////////////////////////////
GeneralOptions()10077 void Texmaker::GeneralOptions()
10078 {
10079 ConfigDialog *confDlg = new ConfigDialog(this);
10080
10081 confDlg->ui.lineEditSvn->setText(svnPath);
10082 confDlg->ui.checkBoxSvn->setChecked(svnEnable);
10083
10084 confDlg->ui.lineEditLualatex->setText(lualatex_command);
10085 confDlg->ui.lineEditXelatex->setText(xelatex_command);
10086 confDlg->ui.lineEditPath->setText(extra_path);
10087 confDlg->ui.lineEditLatex->setText(latex_command);
10088 confDlg->ui.lineEditPdflatex->setText(pdflatex_command);
10089 confDlg->ui.lineEditDvips->setText(dvips_command);
10090 confDlg->ui.lineEditDviviewer->setText(viewdvi_command);
10091 confDlg->ui.lineEditPsviewer->setText(viewps_command);
10092 confDlg->ui.lineEditDvipdfm->setText(dvipdf_command);
10093 confDlg->ui.lineEditPs2pdf->setText(ps2pdf_command);
10094 confDlg->ui.lineEditBibtex->setText(bibtex_command);
10095 confDlg->ui.lineEditMakeindex->setText(makeindex_command);
10096 confDlg->ui.lineEditPdfviewer->setText(viewpdf_command);
10097 if (builtinpdfview) confDlg->ui.radioButtonInternalPdfViewer->setChecked(true);
10098 else confDlg->ui.radioButtonExternalPdfViewer->setChecked(true);
10099 confDlg->ui.checkBoxInternalPdfViewEmbed->setChecked(embedinternalpdf);
10100 confDlg->ui.lineEditMetapost->setText(metapost_command);
10101 confDlg->ui.lineEditGhostscript->setText(ghostscript_command);
10102 confDlg->ui.lineEditAsymptote->setText(asymptote_command);
10103 confDlg->ui.lineEditLatexmk->setText(latexmk_command);
10104 confDlg->ui.lineEditSweave->setText(sweave_command);
10105 if (singleviewerinstance) confDlg->ui.checkBoxSingleInstanceViewer->setChecked(true);
10106 confDlg->ui.checkBoxTempBuild->setChecked(useoutputdir);
10107 confDlg->ui.checkBoxClean->setChecked(clean_exit);
10108
10109 confDlg->ui.comboBoxFont->lineEdit()->setText(EditorFont.family() );
10110 confDlg->ui.comboBoxEncoding->setCurrentIndex(confDlg->ui.comboBoxEncoding->findText(input_encoding, Qt::MatchExactly));
10111
10112 confDlg->ui.spinBoxSize->setValue(EditorFont.pointSize() );
10113 if (wordwrap) {confDlg->ui.checkBoxWordwrap->setChecked(true);}
10114 else {confDlg->ui.checkBoxWordwrap->setChecked(false);}
10115 if (tabspaces) {confDlg->ui.checkBoxTab->setChecked(true);}
10116 else {confDlg->ui.checkBoxTab->setChecked(false);}
10117 confDlg->ui.spinBoxTab->setValue(tabwidth);
10118 if (watchfiles) {confDlg->ui.checkBoxWatcher->setChecked(true);}
10119 else {confDlg->ui.checkBoxWatcher->setChecked(false);}
10120 if (autosave) {confDlg->ui.checkBoxAutoSave->setChecked(true);}
10121 else {confDlg->ui.checkBoxAutoSave->setChecked(false);}
10122 if (showline) {confDlg->ui.checkBoxLinenumber->setChecked(true);}
10123 else {confDlg->ui.checkBoxLinenumber->setChecked(false);}
10124 if (completion) {confDlg->ui.checkBoxCompletion->setChecked(true);}
10125 else {confDlg->ui.checkBoxCompletion->setChecked(false);}
10126 if (inlinespellcheck) {confDlg->ui.checkBoxInlineSpell->setChecked(true);}
10127 else {confDlg->ui.checkBoxInlineSpell->setChecked(false);}
10128
10129 confDlg->ui.lineEditAspellCommand->setText(spell_dic);
10130
10131 if (quickmode==1) {confDlg->ui.radioButton1->setChecked(true); confDlg->ui.lineEditUserquick->setEnabled(false);confDlg->ui.pushButtonWizard->setEnabled(false);}
10132 if (quickmode==2) {confDlg->ui.radioButton2->setChecked(true); confDlg->ui.lineEditUserquick->setEnabled(false);confDlg->ui.pushButtonWizard->setEnabled(false);}
10133 if (quickmode==3) {confDlg->ui.radioButton3->setChecked(true); confDlg->ui.lineEditUserquick->setEnabled(false);confDlg->ui.pushButtonWizard->setEnabled(false);}
10134 if (quickmode==4) {confDlg->ui.radioButton4->setChecked(true); confDlg->ui.lineEditUserquick->setEnabled(false);confDlg->ui.pushButtonWizard->setEnabled(false);}
10135 if (quickmode==5) {confDlg->ui.radioButton5->setChecked(true); confDlg->ui.lineEditUserquick->setEnabled(false);confDlg->ui.pushButtonWizard->setEnabled(false);}
10136 if (quickmode==6) {confDlg->ui.radioButton6->setChecked(true); confDlg->ui.lineEditUserquick->setEnabled(true);confDlg->ui.pushButtonWizard->setEnabled(true);}
10137 if (quickmode==7) {confDlg->ui.radioButton7->setChecked(true); confDlg->ui.lineEditUserquick->setEnabled(false);confDlg->ui.pushButtonWizard->setEnabled(false);}
10138 if (quickmode==8) {confDlg->ui.radioButton8->setChecked(true); confDlg->ui.lineEditUserquick->setEnabled(false);confDlg->ui.pushButtonWizard->setEnabled(false);}
10139 if (quickmode==9) {confDlg->ui.radioButton9->setChecked(true); confDlg->ui.lineEditUserquick->setEnabled(false);confDlg->ui.pushButtonWizard->setEnabled(false);}
10140 if (quickmode==10) {confDlg->ui.radioButton10->setChecked(true); confDlg->ui.lineEditUserquick->setEnabled(false);confDlg->ui.pushButtonWizard->setEnabled(false);}
10141 if (quickmode==11) {confDlg->ui.radioButton11->setChecked(true); confDlg->ui.lineEditUserquick->setEnabled(false);confDlg->ui.pushButtonWizard->setEnabled(false);}
10142 if (quickmode==12) {confDlg->ui.radioButton12->setChecked(true); confDlg->ui.lineEditUserquick->setEnabled(false);confDlg->ui.pushButtonWizard->setEnabled(false);}
10143 if (quickmode==13) {confDlg->ui.radioButton13->setChecked(true); confDlg->ui.lineEditUserquick->setEnabled(false);confDlg->ui.pushButtonWizard->setEnabled(false);}
10144 if (quickmode==14) {confDlg->ui.radioButton14->setChecked(true); confDlg->ui.lineEditUserquick->setEnabled(false);confDlg->ui.pushButtonWizard->setEnabled(false);}
10145 confDlg->ui.lineEditUserquick->setText(userquick_command);
10146 confDlg->ui.lineEditAsyQuick->setText(quick_asy_command);
10147 confDlg->ui.lineEditPrinter->setText(lp_options);
10148
10149 int row=0;
10150 KeysMap::Iterator its, iter;
10151 QString d,f;
10152 for( its = shortcuts.begin(); its != shortcuts.end(); ++its )
10153 {
10154 d=its.key().section("/",0,0);
10155 for( iter = actionstext.begin(); iter != actionstext.end(); ++iter )
10156 {
10157 f=iter.key().section("/",0,0);
10158 if (d==f)
10159 {
10160 QTableWidgetItem *newItem = new QTableWidgetItem(iter.value());
10161 //QTableWidgetItem *newItem = new QTableWidgetItem(*actionstext.find(its.key()));
10162 newItem->setFlags( Qt::ItemIsSelectable | Qt::ItemIsEnabled );
10163 newItem->setData(Qt::UserRole, its.key());
10164 confDlg->ui.shorttableWidget->setRowCount(row+1);
10165 confDlg->ui.shorttableWidget->setItem(row, 0, newItem);
10166 QTableWidgetItem *newItembis = new QTableWidgetItem(its.value());
10167 //QTableWidgetItem *newItem = new QTableWidgetItem(*actionstext.find(its.key()));
10168 newItembis->setFlags( Qt::ItemIsSelectable | Qt::ItemIsEnabled );
10169 newItembis->setData(Qt::UserRole,QString("key"));
10170 confDlg->ui.shorttableWidget->setItem(row, 1,newItembis);
10171 row++;
10172 }
10173 }
10174 }
10175 confDlg->ui.shorttableWidget->horizontalHeader()->resizeSection( 0, 250 );
10176 confDlg->ui.shorttableWidget->verticalHeader()->hide();
10177 confDlg->ui.pushButtonToggleFocus->setText(keyToggleFocus);
10178
10179 QTableWidgetItem *colorItem;
10180
10181 colorItem= new QTableWidgetItem(colorBackground.name());
10182 colorItem->setFlags(Qt::ItemIsSelectable | Qt::ItemIsEnabled | Qt::ItemIsEditable);
10183 confDlg->ui.colortableWidget->setItem(0,1,colorItem);
10184
10185 colorItem= new QTableWidgetItem(colorLine.name());
10186 colorItem->setFlags(Qt::ItemIsSelectable | Qt::ItemIsEnabled | Qt::ItemIsEditable);
10187 confDlg->ui.colortableWidget->setItem(1,1,colorItem);
10188
10189 colorItem= new QTableWidgetItem(colorHighlight.name());
10190 colorItem->setFlags(Qt::ItemIsSelectable | Qt::ItemIsEnabled | Qt::ItemIsEditable);
10191 confDlg->ui.colortableWidget->setItem(2,1,colorItem);
10192
10193 colorItem= new QTableWidgetItem(colorStandard.name());
10194 colorItem->setFlags(Qt::ItemIsSelectable | Qt::ItemIsEnabled | Qt::ItemIsEditable);
10195 confDlg->ui.colortableWidget->setItem(3,1,colorItem);
10196
10197 colorItem= new QTableWidgetItem(colorComment.name());
10198 colorItem->setFlags(Qt::ItemIsSelectable | Qt::ItemIsEnabled | Qt::ItemIsEditable);
10199 confDlg->ui.colortableWidget->setItem(4,1,colorItem);
10200
10201 colorItem= new QTableWidgetItem(colorMath.name());
10202 colorItem->setFlags(Qt::ItemIsSelectable | Qt::ItemIsEnabled | Qt::ItemIsEditable);
10203 confDlg->ui.colortableWidget->setItem(5,1,colorItem);
10204
10205 colorItem= new QTableWidgetItem(colorCommand.name());
10206 colorItem->setFlags(Qt::ItemIsSelectable | Qt::ItemIsEnabled | Qt::ItemIsEditable);
10207 confDlg->ui.colortableWidget->setItem(6,1,colorItem);
10208
10209 colorItem= new QTableWidgetItem(colorKeyword.name());
10210 colorItem->setFlags(Qt::ItemIsSelectable | Qt::ItemIsEnabled | Qt::ItemIsEditable);
10211 confDlg->ui.colortableWidget->setItem(7,1,colorItem);
10212
10213 colorItem= new QTableWidgetItem(colorVerbatim.name());
10214 colorItem->setFlags(Qt::ItemIsSelectable | Qt::ItemIsEnabled | Qt::ItemIsEditable);
10215 confDlg->ui.colortableWidget->setItem(8,1,colorItem);
10216
10217 colorItem= new QTableWidgetItem(colorTodo.name());
10218 colorItem->setFlags(Qt::ItemIsSelectable | Qt::ItemIsEnabled | Qt::ItemIsEditable);
10219 confDlg->ui.colortableWidget->setItem(9,1,colorItem);
10220
10221 colorItem= new QTableWidgetItem(colorKeywordGraphic.name());
10222 colorItem->setFlags(Qt::ItemIsSelectable | Qt::ItemIsEnabled | Qt::ItemIsEditable);
10223 confDlg->ui.colortableWidget->setItem(10,1,colorItem);
10224
10225
10226 colorItem= new QTableWidgetItem(colorNumberGraphic.name());
10227 colorItem->setFlags(Qt::ItemIsSelectable | Qt::ItemIsEnabled | Qt::ItemIsEditable);
10228 confDlg->ui.colortableWidget->setItem(11,1,colorItem);
10229
10230 disconnect(autosaveTimer, SIGNAL(timeout()), this, SLOT(fileBackupAll()));
10231 autosaveTimer->stop();
10232 if (confDlg->exec())
10233 {
10234 listViewerCommands.clear();
10235 for(int row=0; row<confDlg->ui.shorttableWidget->rowCount(); row++ )
10236 {
10237 QString itemtext = confDlg->ui.shorttableWidget->item(row, 0)->text();
10238 QString itemshortcut = confDlg->ui.shorttableWidget->item(row, 1)->text();
10239 QString itemdata=confDlg->ui.shorttableWidget->item(row, 0)->data(Qt::UserRole).toString();
10240 shortcuts.remove(itemdata);
10241 shortcuts.insert(itemdata,itemshortcut);
10242 }
10243 ModifyShortcuts();
10244 keyToggleFocus=confDlg->ui.pushButtonToggleFocus->text();
10245
10246 if (confDlg->ui.radioButton1->isChecked()) quickmode=1;
10247 if (confDlg->ui.radioButton2->isChecked()) quickmode=2;
10248 if (confDlg->ui.radioButton3->isChecked()) quickmode=3;
10249 if (confDlg->ui.radioButton4->isChecked()) quickmode=4;
10250 if (confDlg->ui.radioButton5->isChecked()) quickmode=5;
10251 if (confDlg->ui.radioButton6->isChecked()) quickmode=6;
10252 if (confDlg->ui.radioButton7->isChecked()) quickmode=7;
10253 if (confDlg->ui.radioButton8->isChecked()) quickmode=8;
10254 if (confDlg->ui.radioButton9->isChecked()) quickmode=9;
10255 if (confDlg->ui.radioButton10->isChecked()) quickmode=10;
10256 if (confDlg->ui.radioButton11->isChecked()) quickmode=11;
10257 if (confDlg->ui.radioButton12->isChecked()) quickmode=12;
10258 if (confDlg->ui.radioButton13->isChecked()) quickmode=13;
10259 if (confDlg->ui.radioButton14->isChecked()) quickmode=14;
10260 userquick_command=confDlg->ui.lineEditUserquick->text();
10261 quick_asy_command=confDlg->ui.lineEditAsyQuick->text();
10262 lp_options=confDlg->ui.lineEditPrinter->text();
10263
10264 svnEnable=confDlg->ui.checkBoxSvn->isChecked();
10265 svnPath=confDlg->ui.lineEditSvn->text();
10266
10267 lualatex_command=confDlg->ui.lineEditLualatex->text();
10268 xelatex_command=confDlg->ui.lineEditXelatex->text();
10269 extra_path=confDlg->ui.lineEditPath->text();
10270 latex_command=confDlg->ui.lineEditLatex->text();
10271 pdflatex_command=confDlg->ui.lineEditPdflatex->text();
10272 dvips_command=confDlg->ui.lineEditDvips->text();
10273 viewdvi_command=confDlg->ui.lineEditDviviewer->text();
10274 viewps_command=confDlg->ui.lineEditPsviewer->text();
10275 dvipdf_command=confDlg->ui.lineEditDvipdfm->text();
10276 ps2pdf_command=confDlg->ui.lineEditPs2pdf->text();
10277 bibtex_command=confDlg->ui.lineEditBibtex->text();
10278 makeindex_command=confDlg->ui.lineEditMakeindex->text();
10279 viewpdf_command=confDlg->ui.lineEditPdfviewer->text();
10280 metapost_command=confDlg->ui.lineEditMetapost->text();
10281 if (metapost_command.right(1)!=" ") metapost_command+=" ";
10282 ghostscript_command=confDlg->ui.lineEditGhostscript->text();
10283 asymptote_command=confDlg->ui.lineEditAsymptote->text();
10284 latexmk_command=confDlg->ui.lineEditLatexmk->text();
10285 sweave_command=confDlg->ui.lineEditSweave->text();
10286 builtinpdfview=confDlg->ui.radioButtonInternalPdfViewer->isChecked();
10287 embedinternalpdf=confDlg->ui.checkBoxInternalPdfViewEmbed->isChecked();
10288
10289 if (embedinternalpdf && builtinpdfview)
10290 {
10291 StackedViewers->show();
10292 ViewPdfPanelAct->setEnabled(true);
10293 togglePdfButton->show();
10294 ShowPdfView(false);
10295 ShowSourceView(false);
10296 if (showpdfview)
10297 {
10298 StackedViewers->show();
10299 sourceviewerWidget->hide();
10300 }
10301 else if (showsourceview)
10302 {
10303 StackedViewers->setCurrentWidget(sourceviewerWidget);
10304 StackedViewers->show();
10305 }
10306 else StackedViewers->hide();
10307 }
10308 else
10309 {
10310 if (pdfviewerWidget) {StackedViewers->removeWidget(pdfviewerWidget);delete(pdfviewerWidget);}
10311 //StackedViewers->hide();
10312 ViewPdfPanelAct->setEnabled(false);
10313 togglePdfButton->hide();
10314 if (showsourceview)
10315 {
10316 StackedViewers->setCurrentWidget(sourceviewerWidget);
10317 StackedViewers->show();
10318 }
10319 else StackedViewers->hide();
10320 }
10321 singleviewerinstance=confDlg->ui.checkBoxSingleInstanceViewer->isChecked();
10322 useoutputdir=confDlg->ui.checkBoxTempBuild->isChecked();
10323 clean_exit=confDlg->ui.checkBoxClean->isChecked();
10324
10325 if ((pdfviewerWidget) && keyToggleFocus!="none") pdfviewerWidget->setKeyEditorFocus(QKeySequence(keyToggleFocus));
10326 if (pdfviewerWidget) pdfviewerWidget->setGSCommand(ghostscript_command);
10327 if ((pdfviewerWindow) && keyToggleFocus!="none") pdfviewerWindow->setKeyEditorFocus(QKeySequence(keyToggleFocus));
10328 if (pdfviewerWindow) pdfviewerWindow->setGSCommand(ghostscript_command);
10329
10330 QString fam=confDlg->ui.comboBoxFont->lineEdit()->text();
10331 int si=confDlg->ui.spinBoxSize->value();
10332 QFont F(fam,si);
10333 EditorFont=F;
10334
10335 input_encoding=confDlg->ui.comboBoxEncoding->currentText();
10336 stat3->setText(QString(" %1 ").arg(input_encoding));
10337
10338 wordwrap=confDlg->ui.checkBoxWordwrap->isChecked();
10339 tabspaces=confDlg->ui.checkBoxTab->isChecked();
10340 tabwidth=confDlg->ui.spinBoxTab->value();
10341 watchfiles=confDlg->ui.checkBoxWatcher->isChecked();
10342 autosave=confDlg->ui.checkBoxAutoSave->isChecked();
10343
10344 completion=confDlg->ui.checkBoxCompletion->isChecked();
10345 showline=confDlg->ui.checkBoxLinenumber->isChecked();
10346 inlinespellcheck=confDlg->ui.checkBoxInlineSpell->isChecked();
10347 spell_dic=confDlg->ui.lineEditAspellCommand->text();
10348 if (spellChecker) delete spellChecker;
10349 if (spelldicExist())
10350 {
10351 QString dic=spell_dic.left(spell_dic.length()-4);
10352 spellChecker = new Hunspell(dic.toLatin1()+".aff",dic.toLatin1()+".dic");
10353 }
10354 else spellChecker=0;
10355 QFileInfo fispell(spell_dic);
10356 pdfCheckerLang=fispell.fileName().left(2);
10357 if (!pdfCheckerLang.contains(QRegExp("(de|en|es|fr|id|it|nl|pl|pt|ru)"))) pdfCheckerLang="en";
10358
10359 if (QColor::isValidColor(confDlg->ui.colortableWidget->item(0,1)->text())) colorBackground=QColor(confDlg->ui.colortableWidget->item(0,1)->text());
10360
10361 if (QColor::isValidColor(confDlg->ui.colortableWidget->item(1,1)->text())) colorLine=QColor(confDlg->ui.colortableWidget->item(1,1)->text());
10362
10363 if (QColor::isValidColor(confDlg->ui.colortableWidget->item(2,1)->text())) colorHighlight=QColor(confDlg->ui.colortableWidget->item(2,1)->text());
10364
10365 if (QColor::isValidColor(confDlg->ui.colortableWidget->item(3,1)->text())) colorStandard=QColor(confDlg->ui.colortableWidget->item(3,1)->text());
10366
10367 if (QColor::isValidColor(confDlg->ui.colortableWidget->item(4,1)->text())) colorComment=QColor(confDlg->ui.colortableWidget->item(4,1)->text());
10368
10369 if (QColor::isValidColor(confDlg->ui.colortableWidget->item(5,1)->text())) colorMath=QColor(confDlg->ui.colortableWidget->item(5,1)->text());
10370
10371 if (QColor::isValidColor(confDlg->ui.colortableWidget->item(6,1)->text())) colorCommand=QColor(confDlg->ui.colortableWidget->item(6,1)->text());
10372
10373 if (QColor::isValidColor(confDlg->ui.colortableWidget->item(7,1)->text())) colorKeyword=QColor(confDlg->ui.colortableWidget->item(7,1)->text());
10374
10375 if (QColor::isValidColor(confDlg->ui.colortableWidget->item(8,1)->text())) colorVerbatim=QColor(confDlg->ui.colortableWidget->item(8,1)->text());
10376
10377 if (QColor::isValidColor(confDlg->ui.colortableWidget->item(9,1)->text())) colorTodo=QColor(confDlg->ui.colortableWidget->item(9,1)->text());
10378
10379 if (QColor::isValidColor(confDlg->ui.colortableWidget->item(10,1)->text())) colorKeywordGraphic=QColor(confDlg->ui.colortableWidget->item(10,1)->text());
10380
10381 if (QColor::isValidColor(confDlg->ui.colortableWidget->item(11,1)->text())) colorNumberGraphic=QColor(confDlg->ui.colortableWidget->item(11,1)->text());
10382
10383 QTextCodec* codec = QTextCodec::codecForName(input_encoding.toLatin1());
10384 if(!codec) codec = QTextCodec::codecForLocale();
10385
10386 QString tmpSource =sourceviewerWidget->editor->toPlainText();
10387 sourceviewerWidget->editor->setEncoding(input_encoding);
10388 if (wordwrap) {sourceviewerWidget->editor->setWordWrapMode(QTextOption::WordWrap);}
10389 else {sourceviewerWidget->editor->setWordWrapMode(QTextOption::NoWrap);}
10390 sourceviewerWidget->changeSettings(EditorFont,showline);
10391 sourceviewerWidget->editor->setColors(edcolors());
10392 sourceviewerWidget->editor->highlighter->setColors(hicolors());
10393 QTextStream tsSource( &tmpSource,QIODevice::ReadOnly );
10394 tsSource.setCodec(codec);
10395 sourceviewerWidget->editor->setPlainText( tsSource.readAll() );
10396
10397
10398 if (currentEditorView())
10399 {
10400 LatexEditorView *temp = new LatexEditorView( EditorView,EditorFont,svnEnable,showline,edcolors(),hicolors(),inlinespellcheck,spell_ignored_words,spellChecker,tabspaces,tabwidth,QKeySequence(keyToggleFocus),getName(),userTagsList);
10401 temp=currentEditorView();
10402 FilesMap::Iterator it;
10403 initCompleter();
10404 for( it = filenames.begin(); it != filenames.end(); ++it )
10405 {
10406 QApplication::setOverrideCursor(QCursor(Qt::WaitCursor));
10407 EditorView->setCurrentIndex(EditorView->indexOf(it.key()));
10408 bool MODIFIED =currentEditorView()->editor->document()->isModified();
10409 QString tmp =currentEditorView()->editor->toPlainText();
10410 disconnect(currentEditorView()->editor->document(), SIGNAL(modificationChanged(bool)), this, SLOT(NewDocumentStatus(bool)));
10411 disconnect(currentEditorView()->editor, SIGNAL(spellme()), this, SLOT(editSpell()));
10412 disconnect(currentEditorView()->editor, SIGNAL(tooltiptab()), this, SLOT(editTipTab()));
10413 disconnect(currentEditorView()->editor, SIGNAL(requestUpdateStructure()), this, SLOT(UpdateStructure()));
10414 disconnect(currentEditorView()->editor, SIGNAL(requestpdf(int)),this, SLOT(jumpToPdfline(int)));
10415 disconnect(currentEditorView()->editor->document(), SIGNAL(undoAvailable(bool)),UndoAct, SLOT(setEnabled(bool)));
10416 disconnect(currentEditorView()->editor->document(), SIGNAL(redoAvailable(bool)),RedoAct, SLOT(setEnabled(bool)));
10417 disconnect(currentEditorView()->editor, SIGNAL(copyAvailable(bool)), CutAct, SLOT(setEnabled(bool)));
10418 disconnect(currentEditorView()->editor, SIGNAL(copyAvailable(bool)), CopyAct, SLOT(setEnabled(bool)));
10419 disconnect(currentEditorView()->editor, SIGNAL(numLinesChanged(int)), this, SLOT(refreshAllFromCursor(int)));
10420 disconnect(currentEditorView()->editor, SIGNAL(requestGotoStructure(int)),this, SLOT(jumpToStructure(int)));
10421 disconnect(currentEditorView()->editor, SIGNAL(poshaschanged(int,int)),this, SLOT(showCursorPos(int,int)));
10422 //currentEditorView()->editor->clear();
10423 currentEditorView()->editor->setSpellChecker(spellChecker);
10424 currentEditorView()->editor->highlighter->setSpellChecker(spellChecker);
10425 currentEditorView()->editor->activateInlineSpell(inlinespellcheck);
10426 currentEditorView()->editor->highlighter->activateInlineSpell(inlinespellcheck);
10427 if (wordwrap) {currentEditorView()->editor->setWordWrapMode(QTextOption::WordWrap);}
10428 else {currentEditorView()->editor->setWordWrapMode(QTextOption::NoWrap);}
10429 if (completion) currentEditorView()->editor->setCompleter(completer);
10430 else currentEditorView()->editor->setCompleter(0);
10431 currentEditorView()->editor->setTabSettings(tabspaces,tabwidth);
10432 currentEditorView()->editor->setKeyViewerFocus(QKeySequence(keyToggleFocus));
10433 currentEditorView()->changeSettings(EditorFont,svnEnable,showline);
10434 currentEditorView()->editor->highlighter->setColors(hicolors());
10435 currentEditorView()->editor->setColors(edcolors());
10436
10437 QTextStream ts( &tmp,QIODevice::ReadOnly );
10438 ts.setCodec(codec);
10439 currentEditorView()->editor->setPlainText( ts.readAll() );
10440 currentEditorView()->editor->setLastSavedTime(QDateTime::currentDateTime());
10441 if( MODIFIED ) currentEditorView()->editor->document()->setModified(true );
10442 else currentEditorView()->editor->document()->setModified( false );
10443 connect(currentEditorView()->editor->document(), SIGNAL(modificationChanged(bool)), this, SLOT(NewDocumentStatus(bool)));
10444 connect(currentEditorView()->editor, SIGNAL(spellme()), this, SLOT(editSpell()));
10445 connect(currentEditorView()->editor, SIGNAL(tooltiptab()), this, SLOT(editTipTab()));
10446 connect(currentEditorView()->editor, SIGNAL(requestUpdateStructure()), this, SLOT(UpdateStructure()));
10447 connect(currentEditorView()->editor, SIGNAL(requestpdf(int)),this, SLOT(jumpToPdfline(int)));
10448 connect(currentEditorView()->editor->document(), SIGNAL(undoAvailable(bool)),UndoAct, SLOT(setEnabled(bool)));
10449 connect(currentEditorView()->editor->document(), SIGNAL(redoAvailable(bool)),RedoAct, SLOT(setEnabled(bool)));
10450 connect(currentEditorView()->editor, SIGNAL(copyAvailable(bool)), CutAct, SLOT(setEnabled(bool)));
10451 connect(currentEditorView()->editor, SIGNAL(copyAvailable(bool)), CopyAct, SLOT(setEnabled(bool)));
10452 currentEditorView()->editor->setLastNumLines(currentEditorView()->editor->numoflines());
10453 connect(currentEditorView()->editor, SIGNAL(numLinesChanged(int)), this, SLOT(refreshAllFromCursor(int)));
10454 connect(currentEditorView()->editor, SIGNAL(requestGotoStructure(int)),this, SLOT(jumpToStructure(int)));
10455 connect(currentEditorView()->editor, SIGNAL(poshaschanged(int,int)),this, SLOT(showCursorPos(int,int)));
10456 //UpdateStructure();
10457 //UpdateBibliography();
10458 QApplication::restoreOverrideCursor();
10459 }
10460 EditorView->setCurrentIndex(EditorView->indexOf(temp));
10461 UpdateCaption();
10462 UpdateStructure();
10463 UpdateBibliography();
10464 OutputTextEdit->clear();
10465 OutputTableWidget->hide();
10466 OutputTextEdit->setMaximumHeight(splitter2->sizes().at(1));
10467 separatorline->hide();
10468 //OutputTextEdit->insertLine("Editor settings apply only to new loaded document.");
10469 currentEditorView()->editor->setFocus();
10470 }
10471 }
10472 if (autosave)
10473 {
10474 connect(autosaveTimer, SIGNAL(timeout()), this, SLOT(fileBackupAll()));
10475 autosaveTimer->start(600000);
10476 }
10477 }
10478
ToggleMode()10479 void Texmaker::ToggleMode()
10480 {
10481 //QAction *action = qobject_cast<QAction *>(sender());
10482 if (!singlemode)
10483 {
10484 ToggleAct->setText(tr("Define Current Document as 'Master Document'"));
10485 OutputTextEdit->clear();
10486 OutputTableWidget->hide();
10487 OutputTextEdit->setMaximumHeight(splitter2->sizes().at(1));
10488 separatorline->hide();
10489 logpresent=false;
10490 singlemode=true;
10491 listbibfiles.clear();
10492 listchildfiles.clear();
10493 stat1->setText(QString(" %1 ").arg(tr("Normal Mode")));
10494 ToggleDocAct->setEnabled(false);
10495 return;
10496 }
10497 if (singlemode && currentEditorView())
10498 {
10499 MasterName=getName();
10500 if (MasterName.startsWith("untitled") || MasterName=="")
10501 {
10502 QMessageBox::warning( this,tr("Error"),tr("Could not start the command.")+"\nno valid name for the master document");
10503 return;
10504 }
10505 QString shortName = MasterName;
10506 int pos;
10507 while ( (pos = (int)shortName.indexOf('/')) != -1 ) shortName.remove(0,pos+1);
10508 ToggleAct->setText(tr("Normal Mode (current master document :")+shortName+")");
10509 singlemode=false;
10510 stat1->setText(QString(" %1 ").arg(tr("Master Document :")+shortName));
10511 ToggleDocAct->setEnabled(true);
10512 UpdateStructure();
10513 UpdateBibliography();
10514 return;
10515 }
10516 }
10517
onOtherInstanceMessage(const QString & msg)10518 void Texmaker::onOtherInstanceMessage(const QString &msg) // Added slot for messages to the single instance
10519 {
10520 QStringList argv = msg.split("#!#");
10521 int argc = argv.size();
10522 for ( int i = 1; i < argc; ++i )
10523 {
10524 QString arg = argv[ i ];
10525 if ( arg[0] != '-' ) load( arg );
10526 if ( arg == "-master" ) ToggleMode();
10527 if (( arg == "-line" ) && (i<argc-1)) setLine( argv[ ++i ] );
10528 if ( arg == "-insert" ) insertFromCommandLine( argv[ ++i ] );
10529 }
10530 //A bad (but applicable) trick for activating Texmaker MainWindow //add by S. R. Alavizadeh
10531 //setWindowState(Qt::WindowMinimized);
10532 //setWindowState(windowState() & ~Qt::WindowMinimized | Qt::WindowActive);
10533 //show();
10534 }
10535 ////////////////// VIEW ////////////////
10536
gotoNextDocument()10537 void Texmaker::gotoNextDocument()
10538 {
10539 if ( EditorView->count() < 2 ) return;
10540 int cPage = EditorView->currentIndex() + 1;
10541 if ( cPage >= EditorView->count() ) EditorView->setCurrentIndex( 0 );
10542 else EditorView->setCurrentIndex( cPage );
10543 }
10544
gotoPrevDocument()10545 void Texmaker::gotoPrevDocument()
10546 {
10547 if ( EditorView->count() < 2 ) return;
10548 int cPage = EditorView->currentIndex() - 1;
10549 if ( cPage < 0 ) EditorView->setCurrentIndex( EditorView->count() - 1 );
10550 else EditorView->setCurrentIndex( cPage );
10551 }
10552
SetInterfaceFont()10553 void Texmaker::SetInterfaceFont()
10554 {
10555 #if defined(Q_OS_UNIX) && !defined(Q_OS_MAC)
10556 X11FontDialog *xfdlg = new X11FontDialog(this);
10557 int ft=xfdlg->ui.comboBoxFont->findText (x11fontfamily , Qt::MatchExactly);
10558 xfdlg->ui.comboBoxFont->setCurrentIndex(ft);
10559 xfdlg->ui.spinBoxSize->setValue(x11fontsize);
10560 if (xfdlg->exec())
10561 {
10562 x11fontfamily=xfdlg->ui.comboBoxFont->currentText();
10563 x11fontsize=xfdlg->ui.spinBoxSize->value();
10564 QFont x11Font (x11fontfamily,x11fontsize);
10565 QApplication::setFont(x11Font);
10566 }
10567 #endif
10568 }
10569
gotoBookmark1()10570 void Texmaker::gotoBookmark1()
10571 {
10572 if ( !currentEditorView() ) return;
10573 int l=currentEditorView()->editor->UserBookmark[0];
10574 if (l>0) currentEditorView()->editor->gotoLine(l-1);
10575 }
10576
gotoBookmark2()10577 void Texmaker::gotoBookmark2()
10578 {
10579 if ( !currentEditorView() ) return;
10580 int l=currentEditorView()->editor->UserBookmark[1];
10581 if (l>0) currentEditorView()->editor->gotoLine(l-1);
10582 }
10583
gotoBookmark3()10584 void Texmaker::gotoBookmark3()
10585 {
10586 if ( !currentEditorView() ) return;
10587 int l=currentEditorView()->editor->UserBookmark[2];
10588 if (l>0) currentEditorView()->editor->gotoLine(l-1);
10589 }
10590
10591 //*********************************
dragEnterEvent(QDragEnterEvent * event)10592 void Texmaker::dragEnterEvent(QDragEnterEvent *event)
10593 {
10594 if (event->mimeData()->hasFormat("text/uri-list")) event->acceptProposedAction();
10595 }
10596
dropEvent(QDropEvent * event)10597 void Texmaker::dropEvent(QDropEvent *event)
10598 {
10599 #if defined(Q_OS_WIN32)
10600 QRegExp rx("file:(/+)(.*\\.(?:tex|bib|sty|cls|mp|asy|Rnw|tks))");
10601 #else
10602 QRegExp rx("file:(//)(.*\\.(?:tex|bib|sty|cls|mp|asy|Rnw|tks))");
10603 #endif
10604 QList<QUrl> uris=event->mimeData()->urls();
10605 QString uri;
10606 for (int i = 0; i < uris.size(); ++i)
10607 {
10608 uri=uris.at(i).toString();
10609 if (rx.exactMatch(uri)) {load(rx.cap(2));}
10610 }
10611 event->acceptProposedAction();
10612 }
10613
10614 //***********************************
SetMostUsedSymbols()10615 void Texmaker::SetMostUsedSymbols()
10616 {
10617 for ( int i = 0; i <=11; ++i ) symbolMostused[i]=-1;
10618 QList<int> list_num, list_score;
10619 list_num.clear();
10620 list_score.clear();
10621 for (int i=0; i <412 ; i++)
10622 {
10623 list_num.append(i);
10624 list_score.append(symbolScore[i]);
10625 }
10626 int max;
10627 for (int i = 0; i < 412; i++)
10628 {
10629 max=i;
10630 for (int j = i+1; j < 412; j++)
10631 {
10632 if (list_score.at(j)>list_score.at(max)) max=j;
10633 }
10634 if (max!=i)
10635 {
10636 list_num.swap(i,max);
10637 list_score.swap(i,max);
10638 }
10639 }
10640 for ( int i = 0; i <=11; ++i )
10641 {
10642 if (list_score.at(i)>0) symbolMostused[i]=list_num.at(i);
10643 }
10644 MostUsedListWidget->SetUserPage(symbolMostused);
10645 }
10646
InsertFavoriteSymbols()10647 void Texmaker::InsertFavoriteSymbols()
10648 {
10649 QString actData;
10650 QAction *action = qobject_cast<QAction *>(sender());
10651 if (action)
10652 {
10653 actData=action->data().toString();
10654 QRegExp rxnumber(";([0-9]+)");
10655 int number=-1;
10656 if (!actData.isEmpty())
10657 {
10658 if ( rxnumber.indexIn(actData) != -1) number=rxnumber.cap(1).toInt();
10659 if (!favoriteSymbolList.contains(number)) favoriteSymbolList.append(number);
10660 FavoriteListWidget->SetFavoritePage(favoriteSymbolList);
10661 }
10662 }
10663 }
10664
RemoveFavoriteSymbols()10665 void Texmaker::RemoveFavoriteSymbols()
10666 {
10667 QString actData;
10668 QAction *action = qobject_cast<QAction *>(sender());
10669 if (action)
10670 {
10671 actData=action->data().toString();
10672 QRegExp rxnumber(";([0-9]+)");
10673 int number=-1;
10674 if (!actData.isEmpty())
10675 {
10676 if ( rxnumber.indexIn(actData) != -1) number=rxnumber.cap(1).toInt();
10677 if (favoriteSymbolList.contains(number)) favoriteSymbolList.removeOne(number);
10678 FavoriteListWidget->SetFavoritePage(favoriteSymbolList);
10679 }
10680 }
10681 }
10682
RemoveUserTag()10683 void Texmaker::RemoveUserTag()
10684 {
10685 QString actData;
10686 QAction *action = qobject_cast<QAction *>(sender());
10687 if (action)
10688 {
10689 actData=action->data().toString();
10690 userTagsList.removeOne(actData);
10691 usertagsListWidget->updateList(userTagsList);
10692 if (currentEditorView())
10693 {
10694 FilesMap::Iterator it;
10695 for( it = filenames.begin(); it != filenames.end(); ++it )
10696 {
10697 it.key()->editor->setUserTagsList(userTagsList);
10698 }
10699 }
10700 }
10701
10702 }
10703
AddUserTag()10704 void Texmaker::AddUserTag()
10705 {
10706 AddTagDialog *atDlg = new AddTagDialog(this);
10707 QString item,code;
10708 QString trigger="";
10709 if ( atDlg->exec() )
10710 {
10711 item=atDlg->ui.itemEdit->text();
10712 code=atDlg->ui.tagEdit->toPlainText();
10713 trigger=atDlg->ui.triggerEdit->text();
10714 if (!item.isEmpty() && !code.isEmpty())
10715 {
10716 item.remove("#");
10717 code.remove("#");
10718 trigger.remove("#");
10719 trigger.remove(":");
10720 userTagsList.append(item+"#"+code+"#"+trigger);
10721 usertagsListWidget->updateList(userTagsList);
10722 if (currentEditorView())
10723 {
10724 FilesMap::Iterator it;
10725 for( it = filenames.begin(); it != filenames.end(); ++it )
10726 {
10727 it.key()->editor->setUserTagsList(userTagsList);
10728 }
10729 }
10730
10731 }
10732 }
10733 }
10734
UpdateUserTag()10735 void Texmaker::UpdateUserTag()
10736 {
10737 userTagsList.clear();
10738 QString data, item, code, trigger;
10739 QStringList tagList;
10740 for ( int i = 0; i <usertagsListWidget->count(); ++i )
10741 {
10742 tagList.clear();
10743 data=usertagsListWidget->item(i)->text()+"#"+usertagsListWidget->item(i)->data(Qt::UserRole).toString();
10744 tagList=data.split("#");
10745 item="";
10746 code="";
10747 trigger="";
10748 if (tagList.count()>=2)
10749 {
10750 item=tagList.at(0);
10751 code=tagList.at(1);
10752 if (tagList.count()==3) trigger=tagList.at(2);
10753 if (!item.isEmpty() && !code.isEmpty())
10754 {
10755 item.remove("#");
10756 code.remove("#");
10757 trigger.remove("#");
10758 trigger.remove(":");
10759 userTagsList.append(item+"#"+code+"#"+trigger);
10760 }
10761 }
10762 }
10763 usertagsListWidget->updateList(userTagsList);
10764 if (currentEditorView())
10765 {
10766 FilesMap::Iterator it;
10767 for( it = filenames.begin(); it != filenames.end(); ++it )
10768 {
10769 it.key()->editor->setUserTagsList(userTagsList);
10770 }
10771 }
10772 }
10773
10774
ChangeUserTag()10775 void Texmaker::ChangeUserTag()
10776 {
10777 QString actData;
10778 QAction *action = qobject_cast<QAction *>(sender());
10779 int index=-1;
10780 QString item="";
10781 QString code="";
10782 QString trigger="";
10783 QString newitem,newcode;
10784 QString newtrigger="";
10785 QStringList tagList;
10786 if (action)
10787 {
10788 actData=action->data().toString();
10789 index=userTagsList.indexOf(actData,0);
10790 if (index>-1)
10791 {
10792 tagList= userTagsList.at(index).split("#");
10793 if (tagList.count()>=2)
10794 {
10795 item=tagList.at(0);
10796 code=tagList.at(1);
10797 if (tagList.count()==3) trigger=tagList.at(2);
10798 AddTagDialog *atDlg = new AddTagDialog(this);
10799 atDlg->ui.itemEdit->setText(item);
10800 atDlg->ui.tagEdit->setPlainText(code);
10801 atDlg->ui.triggerEdit->setText(trigger);
10802 if ( atDlg->exec() )
10803 {
10804 item=atDlg->ui.itemEdit->text();
10805 code=atDlg->ui.tagEdit->toPlainText();
10806 trigger=atDlg->ui.triggerEdit->text();
10807 if (!item.isEmpty() && !code.isEmpty())
10808 {
10809 item.remove("#");
10810 code.remove("#");
10811 trigger.remove("#");
10812 trigger.remove(":");
10813 userTagsList.replace(index,item+"#"+code+"#"+trigger);
10814 usertagsListWidget->updateList(userTagsList);
10815 if (currentEditorView())
10816 {
10817 FilesMap::Iterator it;
10818 for( it = filenames.begin(); it != filenames.end(); ++it )
10819 {
10820 it.key()->editor->setUserTagsList(userTagsList);
10821 }
10822 }
10823
10824 }
10825 }
10826 }
10827 }
10828 }
10829
10830 }
10831
ModifyShortcuts()10832 void Texmaker::ModifyShortcuts()
10833 {
10834 KeysMap::Iterator its;
10835 QString d,f,s;
10836 QList<QAction *> listaction;
10837 listaction << toolMenu->actions();
10838 listaction << editMenu->actions();
10839 listaction << NextDocAct << PrevDocAct;
10840 listaction << latex1Menu->actions();
10841 listaction << latex11Menu->actions();
10842 listaction << latex12Menu->actions();
10843 listaction << latex13Menu->actions();
10844 listaction << latex14Menu->actions();
10845 listaction << latex15Menu->actions();
10846 listaction << latex16Menu->actions();
10847 listaction << latex17Menu->actions();
10848 listaction << latex18Menu->actions();
10849 listaction << math1Menu->actions();
10850 listaction << math11Menu->actions();
10851 listaction << math12Menu->actions();
10852 listaction << math13Menu->actions();
10853 listaction << math14Menu->actions();
10854 QListIterator<QAction*> iterator(listaction);
10855 actionstext.clear();
10856 while ( iterator.hasNext() )
10857 {
10858 QAction *action=iterator.next();
10859 if (action && (!action->menu()) && (!action->data().toString().isEmpty()))
10860 {
10861 actionstext.insert(action->data().toString(),action->text());
10862 d=action->data().toString().section("/",0,0);
10863 //action->setShortcut(QKeySequence(""));
10864 for( its = shortcuts.begin(); its != shortcuts.end(); ++its )
10865 {
10866 f=its.key().section("/",0,0);
10867 s=its.value();
10868 if (f==d) action->setShortcut(QKeySequence(""));
10869 if (f==d && s!="none" && !s.isEmpty())
10870 { action->setShortcut(QKeySequence(s));}
10871 }
10872 // its=shortcuts.find(action->data().toString());
10873 // if (its!=shortcuts.end())
10874 // {
10875 // s=*its;
10876 // if (s!="none" && !s.isEmpty()) action->setShortcut(s);
10877 // }
10878 //QString s=*shortcuts.find(action->data().toString());
10879 //if (s!="none" && !s.isEmpty()) action->setShortcut(s);
10880 }
10881 }
10882 }
10883
initCompleter()10884 void Texmaker::initCompleter()
10885 {
10886 QTextCodec *codec = QTextCodec::codecForName("UTF-8");
10887 QAbstractItemModel *model;
10888 QFile tagsfile(":/completion/completion.txt");
10889
10890 #if defined(Q_OS_UNIX) && !defined(Q_OS_MAC)
10891
10892 #ifdef USB_VERSION
10893 QFile userTagsfile(QCoreApplication::applicationDirPath()+"/completion.txt");
10894 #else
10895 QFile userTagsfile(PREFIX"/share/texmaker/completion.txt");
10896 #endif
10897
10898 #endif
10899 #if defined(Q_OS_MAC)
10900 QFile userTagsfile(QCoreApplication::applicationDirPath() + "/../Resources/completion.txt");
10901 #endif
10902 #if defined(Q_OS_WIN32)
10903 QFile userTagsfile(QCoreApplication::applicationDirPath()+"/completion.txt");
10904 #endif
10905 if (!tagsfile.open(QFile::ReadOnly)) model=new QStringListModel(completer);
10906
10907 QApplication::setOverrideCursor(QCursor(Qt::WaitCursor));
10908 QStringList words;
10909 QString line;
10910 QTextStream tscompleter(&tagsfile);
10911 tscompleter.setCodec(codec);
10912 while (!tscompleter.atEnd())
10913 {
10914 line = tscompleter.readLine();
10915 if (!line.isEmpty()) words.append(line.remove("\n"));
10916 }
10917
10918 if (userTagsfile.open(QFile::ReadOnly))
10919 {
10920 QTextStream usertscompleter(&userTagsfile);
10921 usertscompleter.setCodec(codec);
10922 while (!usertscompleter.atEnd())
10923 {
10924 line = usertscompleter.readLine();
10925 if (!line.isEmpty()) words.append(line.remove("\n"));
10926 }
10927 }
10928 for (int i=0; i<userCompletionList.count();++i)
10929 {
10930 words.append(userCompletionList.at(i));
10931 }
10932 words.removeDuplicates();
10933 words.sort();
10934
10935 QApplication::restoreOverrideCursor();
10936 model=new QStringListModel(words, completer);
10937 completer->setModel(model);
10938 completer->setModelSorting(QCompleter::CaseSensitivelySortedModel);
10939 completer->setCaseSensitivity(Qt::CaseSensitive);
10940 completer->setWrapAround(false);
10941 }
10942
updateCompleter()10943 void Texmaker::updateCompleter()
10944 {
10945 QStringList words;
10946 QString item;
10947 QStringList types,extraBibList,extraLabelList;
10948 types << QLatin1String("cite") << QLatin1String("nocite") << QLatin1String("footcite")
10949 << QLatin1String("citep") << QLatin1String("ref")
10950 << QLatin1String("pageref") << QLatin1String("eqref")
10951 << QLatin1String("autoref");
10952 QRegExp macroName("\\\\("+types.join("|")+")\\{(.*)\\}", Qt::CaseInsensitive);
10953 macroName.setMinimal(true);
10954 for (int i=0; i<completer->model()->rowCount();++i)
10955 {
10956 item=completer->model()->data(completer->model()->index(i,0)).toString();
10957 if (!item.contains(macroName)) {words.append(item);}
10958 }
10959
10960 words.append("\\cite{"+QString(0x2022)+"}");
10961 words.append("\\nocite{"+QString(0x2022)+"}");
10962 words.append("\\footcite{"+QString(0x2022)+"}");
10963 words.append("\\citep{"+QString(0x2022)+"}");
10964 words.append("\\ref{"+QString(0x2022)+"}");
10965 words.append("\\pageref{"+QString(0x2022)+"}");
10966 words.append("\\eqref{"+QString(0x2022)+"}");
10967 words.append("\\autoref{"+QString(0x2022)+"}");
10968
10969 for (int i=0; i<userCompletionList.count();++i)
10970 {
10971 if (userCompletionList.at(i).contains("#bib#")) extraBibList.append(userCompletionList.at(i));
10972 if (userCompletionList.at(i).contains("#label#")) extraLabelList.append(userCompletionList.at(i));
10973 }
10974
10975 QAbstractItemModel *model;
10976 QString tag;
10977 for (int i=0; i<bibitem.count();++i)
10978 {
10979 words.append("\\nocite{"+bibitem.at(i)+"}");
10980 words.append("\\cite{"+bibitem.at(i)+"}");
10981 words.append("\\footcite{"+bibitem.at(i)+"}");
10982 words.append("\\citep{"+bibitem.at(i)+"}");
10983 for (int j=0; j<extraBibList.count();++j)
10984 {
10985 tag=extraBibList.at(j);
10986 tag.replace("#bib#",bibitem.at(i));
10987 words.append(tag);
10988 }
10989 }
10990 for (int i=0; i<labelitem.count();++i)
10991 {
10992 words.append("\\ref{"+labelitem.at(i)+"}");
10993 words.append("\\pageref{"+labelitem.at(i)+"}");
10994 words.append("\\eqref{"+labelitem.at(i)+"}");
10995 words.append("\\autoref{"+labelitem.at(i)+"}");
10996 for (int j=0; j<extraLabelList.count();++j)
10997 {
10998 tag=extraLabelList.at(j);
10999 tag.replace("#label#",labelitem.at(i));
11000 words.append(tag);
11001 }
11002 }
11003 for (int j=0; j<extraBibList.count();++j)
11004 {
11005 tag=extraBibList.at(j);
11006 tag.replace("#bib#",QString(0x2022));
11007 words.removeOne(extraBibList.at(j));
11008 words.append(tag);
11009 }
11010 for (int j=0; j<extraLabelList.count();++j)
11011 {
11012 tag=extraLabelList.at(j);
11013 tag.replace("#label#",QString(0x2022));
11014 words.removeOne(extraLabelList.at(j));
11015 words.append(tag);
11016 }
11017 words.removeDuplicates();
11018 words.sort();
11019
11020 model=new QStringListModel(words, completer);
11021 completer->setModel(model);
11022 completer->setModelSorting(QCompleter::CaseSensitivelySortedModel);
11023 completer->setCaseSensitivity(Qt::CaseSensitive);
11024 completer->setWrapAround(false);
11025 }
11026
spelldicExist()11027 bool Texmaker::spelldicExist()
11028 {
11029 QString affdic=spell_dic.left(spell_dic.length()-4)+".aff";
11030 QFileInfo fidic(spell_dic);
11031 QFileInfo fiaff(affdic);
11032 return (fidic.exists() && fidic.isReadable() && fiaff.exists() && fiaff.isReadable());
11033 }
11034
updateTranslation()11035 void Texmaker::updateTranslation()
11036 {
11037 QAction *action = qobject_cast<QAction *>(sender());
11038 QString lang=action->text();
11039 TexmakerApp::instance()->language=lang;
11040 QMessageBox::information( this,"Texmaker",tr("The language setting will take effect after restarting the application."));
11041 }
11042
11043 // void Texmaker::updateAppearance()
11044 // {
11045 // QAction *action = qobject_cast<QAction *>(sender());
11046 // QString style=action->text();
11047 // modern_style=(action->text()=="Modern");
11048 // QMessageBox::information( this,"Texmaker",tr("The appearance setting will take effect after restarting the application."));
11049 // }
11050
disableToolsActions()11051 void Texmaker::disableToolsActions()
11052 {
11053 QList<QAction *> listaction;
11054 listaction << toolMenu->actions();
11055 listaction << user12Menu->actions();
11056 //listaction << optionsMenu->actions();
11057 listaction << runToolBar->actions();
11058 QListIterator<QAction*> iterator(listaction);
11059 while ( iterator.hasNext() )
11060 {
11061 QAction *action=iterator.next();
11062 action->setEnabled(false);
11063 }
11064 QTimer::singleShot(5000,this, SLOT(enableToolsActions()));
11065 }
11066
enableToolsActions()11067 void Texmaker::enableToolsActions()
11068 {
11069 QList<QAction *> listaction;
11070 listaction << toolMenu->actions();
11071 listaction << user12Menu->actions();
11072 //listaction << optionsMenu->actions();
11073 listaction << runToolBar->actions();
11074 QListIterator<QAction*> iterator(listaction);
11075 while ( iterator.hasNext() )
11076 {
11077 QAction *action=iterator.next();
11078 action->setEnabled(true);
11079 }
11080 }
11081
clipboardDataChanged()11082 void Texmaker::clipboardDataChanged()
11083 {
11084 if ( !currentEditorView() ) return;
11085 PasteAct->setEnabled(!QApplication::clipboard()->text().isEmpty());
11086 }
11087
refreshAll()11088 void Texmaker::refreshAll()
11089 {
11090 if ( !currentEditorView() ) return;
11091 disconnect(currentEditorView()->editor, SIGNAL(requestUpdateStructure()), this, SLOT(UpdateStructure()));
11092 currentEditorView()->editor->highlighter->rehighlight();
11093 UpdateStructure();
11094 connect(currentEditorView()->editor, SIGNAL(requestUpdateStructure()), this, SLOT(UpdateStructure()));
11095 }
11096
refreshAllFromCursor(int newnumlines)11097 void Texmaker::refreshAllFromCursor(int newnumlines)
11098 {
11099 disconnect(currentEditorView()->editor, SIGNAL(requestUpdateStructure()), this, SLOT(UpdateStructure()));
11100 int oldnumlines=currentEditorView()->editor->getLastNumLines();
11101 int delta=newnumlines-oldnumlines;
11102 QTextBlock p = currentEditorView()->editor->textCursor().block();
11103 int currentline=p.blockNumber();
11104 int i=currentline-1;
11105 QList<int> start,end;
11106 /* QMapIterator<int, int> it(currentEditorView()->editor->foldedLines);
11107 while (it.hasNext()) {
11108 it.next();
11109 qDebug() << "avant folded" << it.key() << ":" << it.value();
11110 }*/
11111 while (p.isValid())
11112 {
11113 if (currentEditorView()->editor->foldedLines.keys().contains(i))
11114 {
11115 start.append(i+delta);
11116 end.append(currentEditorView()->editor->foldedLines[i]+delta);
11117 currentEditorView()->editor->foldedLines.remove(i);
11118 }
11119 i++;
11120 p = p.next();
11121 }
11122 for (int i =0; i <start.count(); i++) currentEditorView()->editor->foldedLines.insert(start[i],end[i]);
11123 /* QMapIterator<int, int> itbis(currentEditorView()->editor->foldedLines);
11124 while (itbis.hasNext()) {
11125 itbis.next();
11126 qDebug() << "apres folded" << itbis.key() << ":" << itbis.value();
11127 }
11128 qDebug() << "**********";*/
11129 /*QList<int> listofmodifiedlines;
11130 const QList<StructItem>& structure = currentEditorView()->editor->getStructItems();
11131 for (int j = 0; j < structure.count(); j++)
11132 {
11133 l=structure.at(j).line;
11134 if (l>=currentline)
11135 {
11136 listofmodifiedlines.append(l+delta);
11137 }
11138 }
11139 int i=currentline;
11140 while (p.isValid())
11141 {
11142 if (listofmodifiedlines.contains(i))
11143 {
11144 currentEditorView()->editor->highlighter->rehighlightBlock(p);
11145 }
11146 i++;
11147 p = p.next();
11148 }
11149 refreshRange();
11150 //UpdateStructure();*/
11151 connect(currentEditorView()->editor, SIGNAL(requestUpdateStructure()), this, SLOT(UpdateStructure()));
11152 refreshRange();
11153 currentEditorView()->editor->setLastNumLines(newnumlines);
11154 }
11155
refreshRange()11156 void Texmaker::refreshRange()
11157 {
11158 currentEditorView()->editor->foldableLines.clear();
11159 int endpreamble = currentEditorView()->editor->searchLine("\\begin{document}");
11160 if (endpreamble>1) currentEditorView()->editor->foldableLines.insert(0,endpreamble-1);
11161 int nb=StructureTreeWidget->topLevelItemCount();
11162 if (nb>0)
11163 {
11164 for (int i = 0; i < nb; i++)
11165 {
11166 ParseTree(StructureTreeWidget->topLevelItem(i));
11167 }
11168 }
11169 currentEditorView()->editor->matchAll();
11170 }
11171
jumpToStructure(int line)11172 void Texmaker::jumpToStructure(int line)
11173 {
11174 const QList<StructItem>& structure = currentEditorView()->editor->getStructItems();
11175 int index=-1;
11176 for (int j = 0; j < structure.count(); j++)
11177 {
11178 if (structure.at(j).cursor.block().blockNumber()==line) {index=j; break;}
11179 }
11180 if (index<0) return;
11181 QList<QTreeWidgetItem *> fItems=StructureTreeWidget->findItems (structure.at(index).item,Qt::MatchRecursive,0);
11182
11183 if (fItems.size()>0 )
11184 {
11185 for (int i = 0; i< fItems.size(); i++)
11186 {
11187 if ((fItems.at(i)) && (fItems.at(i)->text(1)==QString::number(index)))
11188 {
11189 StructureTreeWidget->scrollToItem(fItems.at(i),QAbstractItemView::EnsureVisible);
11190 StructureTreeWidget->setCurrentItem(fItems.at(i));
11191 }
11192 }
11193 }
11194 }
11195
mainWindowActivated()11196 void Texmaker::mainWindowActivated()
11197 {
11198 if (watchfiles) QTimer::singleShot(0, this, SLOT(checkModifiedOutsideAll()));
11199 }
11200
11201
ToggleStructurePanel()11202 void Texmaker::ToggleStructurePanel()
11203 {
11204 ShowStructView(true);
11205 }
11206
ToggleLogPanel()11207 void Texmaker::ToggleLogPanel()
11208 {
11209 ShowOutputView(true);
11210 }
11211
TogglePdfPanel()11212 void Texmaker::TogglePdfPanel()
11213 {
11214 ShowPdfView(true);
11215 }
11216
ToggleSourcePanel()11217 void Texmaker::ToggleSourcePanel()
11218 {
11219 ShowSourceView(true);
11220 }
11221
ToggleFilesPanel()11222 void Texmaker::ToggleFilesPanel()
11223 {
11224 ShowFilesView(true);
11225 }
11226
ShowStructView(bool change)11227 void Texmaker::ShowStructView(bool change)
11228 {
11229 int pos=0;
11230 QTextCursor cur;
11231 if (currentEditorView() )
11232 {
11233 cur=currentEditorView()->editor->textCursor();
11234 pos=cur.position();
11235 }
11236 if (change) showstructview=!showstructview;
11237 if (showstructview)
11238 {
11239 splitter3->show();
11240 //LeftPanelFrameBis->show();
11241 }
11242 else
11243 {
11244 splitter3->hide();
11245 //LeftPanelFrameBis->hide();
11246 if (currentEditorView())
11247 {
11248 cur.setPosition(pos,QTextCursor::MoveAnchor);
11249 currentEditorView()->editor->setTextCursor(cur);
11250 currentEditorView()->editor->setFocus();
11251 }
11252 }
11253 ViewStructurePanelAct->setChecked(showstructview);
11254 toggleStructureButton->setEnabled(showstructview);
11255 }
11256
ShowOutputView(bool change)11257 void Texmaker::ShowOutputView(bool change)
11258 {
11259 if (change) showoutputview=!showoutputview;
11260 if (showoutputview)
11261 {
11262 Outputframe->show();
11263 splitter2Changed();
11264 if (currentEditorView()) QTimer::singleShot(10,currentEditorView()->editor, SLOT(setCursorVisible()));
11265 }
11266 else
11267 {
11268 Outputframe->hide();
11269 }
11270 ViewLogPanelAct->setChecked(showoutputview);
11271 toggleLogButton->setEnabled(showoutputview);
11272 }
11273
ShowPdfView(bool change)11274 void Texmaker::ShowPdfView(bool change)
11275 {
11276 disconnect(ViewPdfPanelAct, SIGNAL(triggered()), this, SLOT(TogglePdfPanel()));
11277 disconnect(togglePdfButton, SIGNAL( clicked() ), this, SLOT(TogglePdfPanel() ) );
11278 disconnect(ViewSourcePanelAct, SIGNAL(triggered()), this, SLOT(ToggleSourcePanel()));
11279 disconnect(toggleSourceButton, SIGNAL( clicked() ), this, SLOT(ToggleSourcePanel() ) );
11280 if (change) showpdfview=!showpdfview;
11281 if (showpdfview)
11282 {
11283 sourceviewerWidget->hide();
11284 if (pdfviewerWidget) StackedViewers->setCurrentWidget(pdfviewerWidget);
11285 StackedViewers->show();
11286 showsourceview=false;
11287 ViewSourcePanelAct->setChecked(showsourceview);
11288 toggleSourceButton->setEnabled(showsourceview);
11289 }
11290 else
11291 {
11292 StackedViewers->hide();
11293 }
11294 ViewPdfPanelAct->setChecked(showpdfview);
11295 togglePdfButton->setEnabled(showpdfview);
11296 connect(ViewPdfPanelAct, SIGNAL(triggered()), this, SLOT(TogglePdfPanel()));
11297 connect(togglePdfButton, SIGNAL( clicked() ), this, SLOT(TogglePdfPanel() ) );
11298 connect(ViewSourcePanelAct, SIGNAL(triggered()), this, SLOT(ToggleSourcePanel()));
11299 connect(toggleSourceButton, SIGNAL( clicked() ), this, SLOT(ToggleSourcePanel() ) );
11300 }
11301
ShowSourceView(bool change)11302 void Texmaker::ShowSourceView(bool change)
11303 {
11304 disconnect(ViewPdfPanelAct, SIGNAL(triggered()), this, SLOT(TogglePdfPanel()));
11305 disconnect(togglePdfButton, SIGNAL( clicked() ), this, SLOT(TogglePdfPanel() ) );
11306 disconnect(ViewSourcePanelAct, SIGNAL(triggered()), this, SLOT(ToggleSourcePanel()));
11307 disconnect(toggleSourceButton, SIGNAL( clicked() ), this, SLOT(ToggleSourcePanel() ) );
11308 if (change) showsourceview=!showsourceview;
11309 if (showsourceview)
11310 {
11311 StackedViewers->setCurrentWidget(sourceviewerWidget);
11312 sourceviewerWidget->show();
11313 StackedViewers->show();
11314 showpdfview=false;
11315 ViewPdfPanelAct->setChecked(showpdfview);
11316 togglePdfButton->setEnabled(showpdfview);
11317 }
11318 else
11319 {
11320 StackedViewers->hide();
11321 }
11322 ViewSourcePanelAct->setChecked(showsourceview);
11323 toggleSourceButton->setEnabled(showsourceview);
11324 connect(ViewPdfPanelAct, SIGNAL(triggered()), this, SLOT(TogglePdfPanel()));
11325 connect(togglePdfButton, SIGNAL( clicked() ), this, SLOT(TogglePdfPanel() ) );
11326 connect(ViewSourcePanelAct, SIGNAL(triggered()), this, SLOT(ToggleSourcePanel()));
11327 connect(toggleSourceButton, SIGNAL( clicked() ), this, SLOT(ToggleSourcePanel() ) );
11328 }
11329
ShowFilesView(bool change)11330 void Texmaker::ShowFilesView(bool change)
11331 {
11332 if (change) showfilesview=!showfilesview;
11333 if (showfilesview)
11334 {
11335 OpenedFilesListWidget->show();
11336 }
11337 else
11338 {
11339 OpenedFilesListWidget->hide();
11340 }
11341 ViewOpenedFilesPanelAct->setChecked(showfilesview);
11342 }
11343
ToggleFullScreen()11344 void Texmaker::ToggleFullScreen()
11345 {
11346 if(FullScreenAct->isChecked())
11347 {
11348 windowstate=saveState(0);
11349 setWindowState(Qt::WindowFullScreen);
11350 restoreState(fullscreenstate,1);
11351 }
11352 else
11353 {
11354 fullscreenstate=saveState(1);
11355 setWindowState(Qt::WindowNoState);
11356 restoreState(windowstate,0);
11357 }
11358 }
11359
EditUserCompletion()11360 void Texmaker::EditUserCompletion()
11361 {
11362 UserCompletionDialog *ucDlg = new UserCompletionDialog(this,userCompletionList);
11363 QTextCodec *codec = QTextCodec::codecForName("UTF-8");
11364 QFile tagsfile(":/completion/completion.txt");
11365 if (tagsfile.open(QFile::ReadOnly))
11366 {
11367 QTextStream tscompleter(&tagsfile);
11368 tscompleter.setCodec(codec);
11369 ucDlg->ui.plainTextEdit->setPlainText( tscompleter.readAll() );
11370 }
11371 if ( ucDlg->exec() )
11372 {
11373 userCompletionList=ucDlg->userlist;
11374 initCompleter();
11375 updateCompleter();
11376 if (currentEditorView())
11377 {
11378 if (completion) currentEditorView()->editor->setCompleter(completer);
11379 else currentEditorView()->editor->setCompleter(0);
11380 currentEditorView()->editor->matchAll();
11381 }
11382 }
11383 }
11384
addBibFiles(QString param)11385 void Texmaker::addBibFiles(QString param)
11386 {
11387 QString finame;
11388 if (singlemode) {finame=getName();}
11389 else {finame=MasterName;}
11390 QFileInfo fi(finame);
11391 QString name=fi.absoluteFilePath();
11392 QString flname=fi.fileName();
11393 QString basename=name.left(name.length()-flname.length());
11394 QString fname;
11395
11396 QStringList fl=param.split(",");
11397 for (int i = 0; i< fl.count(); i++)
11398 {
11399 fname=fl.at(i);
11400 if (fname.right(4)==".bib") fname=basename+fname;
11401 else fname=basename+fname+".bib";
11402 QFileInfo fi(fname);
11403 if (fi.exists() && fi.isReadable()) listbibfiles.append(fname);
11404 else
11405 {
11406 fname=fl.at(i);
11407 if (fname.right(4)!=".bib") fname=fname+".bib";
11408 QFileInfo fi(fname);
11409 if (fi.isAbsolute() && fi.exists() && fi.isReadable()) listbibfiles.append(fname);
11410 }
11411 }
11412 }
11413
addIncludeFiles(QString param)11414 void Texmaker::addIncludeFiles(QString param)
11415 {
11416 QString finame;
11417 if (singlemode) {finame=getName();}
11418 else {finame=MasterName;}
11419 QFileInfo fi(finame);
11420 QString name=fi.absoluteFilePath();
11421 QString flname=fi.fileName();
11422 QString basename=name.left(name.length()-flname.length());
11423 QString fname;
11424
11425 QStringList fl=param.split(",");
11426 for (int i = 0; i< fl.count(); i++)
11427 {
11428 fname=fl.at(i);
11429 if (fname.right(4)==".tex") fname=basename+fname;
11430 else fname=basename+fname+".tex";
11431 QFileInfo fi(fname);
11432 if (fi.exists() && fi.isReadable()) listchildfiles.append(fname);
11433 else
11434 {
11435 fname=fl.at(i);
11436 if (fname.right(4)!=".tex") fname=fname+".tex";
11437 QFileInfo fi(fname);
11438 if (fi.isAbsolute() && fi.exists() && fi.isReadable()) listchildfiles.append(fname);
11439 }
11440 }
11441 }
11442
loadIncludeFiles(QString param,QString extension)11443 void Texmaker::loadIncludeFiles(QString param, QString extension)
11444 {
11445 QString finame;
11446 if (singlemode) {finame=getName();}
11447 else {finame=MasterName;}
11448 QFileInfo fi(finame);
11449 QString name=fi.absoluteFilePath();
11450 QString flname=fi.fileName();
11451 QString basename=name.left(name.length()-flname.length());
11452 QString fname;
11453
11454 QStringList fl=param.split(",");
11455 for (int i = 0; i< fl.count(); i++)
11456 {
11457 fname=fl.at(i);
11458 if (fname.right(4)==extension) fname=basename+fname;
11459 else fname=basename+fname+extension;
11460 QFileInfo fi(fname);
11461 if (fi.exists() && fi.isReadable()) load(fname);
11462 else
11463 {
11464 fname=fl.at(i);
11465 if (fname.right(4)!=extension) fname=fname+extension;
11466 QFileInfo fi(fname);
11467 if (fi.isAbsolute() && fi.exists() && fi.isReadable()) load(fname);
11468 }
11469 }
11470 }
11471
showCursorPos(int li,int col)11472 void Texmaker::showCursorPos(int li, int col)
11473 {
11474 QString linenumber;
11475 if (col>0) linenumber.sprintf("L: %d C: %d", li,col);
11476 else linenumber.sprintf("L: %d C: %d", li,1);
11477 posLabel->setText(linenumber);
11478 }
11479
keyPressEvent(QKeyEvent * event)11480 void Texmaker::keyPressEvent(QKeyEvent *event)
11481 {
11482 if ((event->key() == Qt::Key_Escape) && showoutputview)
11483 {
11484 ShowOutputView(true);
11485 }
11486 else QMainWindow::keyPressEvent(event);
11487 }
11488
customContentsMenuStructure(const QPoint & pos)11489 void Texmaker::customContentsMenuStructure( const QPoint &pos )
11490 {
11491 QMenu *menu = QMainWindow::createPopupMenu();
11492 menu->addSeparator();
11493 viewPstricksAct->setChecked(showPstricks);
11494 menu->addAction(viewPstricksAct);
11495 viewMpAct->setChecked(showMp);
11496 menu->addAction(viewMpAct);
11497 viewTikzAct->setChecked(showTikz);
11498 menu->addAction(viewTikzAct);
11499 viewAsyAct->setChecked(showAsy);
11500 menu->addAction(viewAsyAct);
11501
11502 QPoint globalPos = LeftPanelToolBar->mapToGlobal(pos);
11503 menu->exec( globalPos );
11504 }
11505
TogglePstricks()11506 void Texmaker::TogglePstricks()
11507 {
11508 if (showPstricks)
11509 {
11510 if (LeftPanelToolBar->actions().contains(pstricksAct)) LeftPanelToolBar->removeAction(pstricksAct);
11511 }
11512 else if (!LeftPanelToolBar->actions().contains(pstricksAct)) LeftPanelToolBar->addAction(pstricksAct);
11513 showPstricks=!showPstricks;
11514 }
ToggleMetapost()11515 void Texmaker::ToggleMetapost()
11516 {
11517 if (showMp)
11518 {
11519 if (LeftPanelToolBar->actions().contains(mpAct)) LeftPanelToolBar->removeAction(mpAct);
11520 }
11521 else if (!LeftPanelToolBar->actions().contains(mpAct)) LeftPanelToolBar->addAction(mpAct);
11522 showMp=!showMp;
11523 }
ToggleTikz()11524 void Texmaker::ToggleTikz()
11525 {
11526 if (showTikz)
11527 {
11528 if (LeftPanelToolBar->actions().contains(tikzAct)) LeftPanelToolBar->removeAction(tikzAct);
11529 }
11530 else if (!LeftPanelToolBar->actions().contains(tikzAct)) LeftPanelToolBar->addAction(tikzAct);
11531 showTikz=!showTikz;
11532 }
ToggleAsymptote()11533 void Texmaker::ToggleAsymptote()
11534 {
11535 if (showAsy)
11536 {
11537 if (LeftPanelToolBar->actions().contains(asyAct)) LeftPanelToolBar->removeAction(asyAct);
11538 }
11539 else if (!LeftPanelToolBar->actions().contains(asyAct)) LeftPanelToolBar->addAction(asyAct);
11540 showAsy=!showAsy;
11541 }
11542
customContentsMenuMain(const QPoint & pos)11543 void Texmaker::customContentsMenuMain( const QPoint &pos )
11544 {
11545 QMenu *menu = QMainWindow::createPopupMenu();
11546 menu->addSeparator();
11547 showemphasisAct->setChecked(showEmphasis);
11548 menu->addAction(showemphasisAct);
11549
11550 shownewlineAct->setChecked(showNewline);
11551 menu->addAction(shownewlineAct);
11552
11553 showmathmodeAct->setChecked(showMathmode);
11554 menu->addAction(showmathmodeAct);
11555
11556 showindiceAct->setChecked(showIndice);
11557 menu->addAction(showindiceAct);
11558
11559 showpuissanceAct->setChecked(showPuissance);
11560 menu->addAction(showpuissanceAct);
11561
11562 showsmallfracAct->setChecked(showSmallfrac);
11563 menu->addAction(showsmallfracAct);
11564
11565 showdfracAct->setChecked(showDfrac);
11566 menu->addAction(showdfracAct);
11567
11568 showracineAct->setChecked(showRacine);
11569 menu->addAction(showracineAct);
11570
11571 QPoint globalPos = centralToolBar->mapToGlobal(pos);
11572 menu->exec( globalPos );
11573 }
11574
ToggleEmphasis()11575 void Texmaker::ToggleEmphasis()
11576 {
11577 if (showEmphasis)
11578 {
11579 if (centralToolBar->actions().contains(emphasisAct)) centralToolBar->removeAction(emphasisAct);
11580 }
11581 else if (!centralToolBar->actions().contains(emphasisAct)) centralToolBar->addAction(emphasisAct);
11582 showEmphasis=!showEmphasis;
11583 }
11584
ToggleNewline()11585 void Texmaker::ToggleNewline()
11586 {
11587 if (showNewline)
11588 {
11589 if (centralToolBar->actions().contains(newlineAct)) centralToolBar->removeAction(newlineAct);
11590 }
11591 else if (!centralToolBar->actions().contains(newlineAct)) centralToolBar->addAction(newlineAct);
11592 showNewline=!showNewline;
11593 }
11594
ToggleMathmode()11595 void Texmaker::ToggleMathmode()
11596 {
11597 if (showMathmode)
11598 {
11599 if (centralToolBar->actions().contains(mathmodeAct)) centralToolBar->removeAction(mathmodeAct);
11600 }
11601 else if (!centralToolBar->actions().contains(mathmodeAct)) centralToolBar->addAction(mathmodeAct);
11602 showMathmode=!showMathmode;
11603 }
11604
ToggleIndice()11605 void Texmaker::ToggleIndice()
11606 {
11607 if (showIndice)
11608 {
11609 if (centralToolBar->actions().contains(indiceAct)) centralToolBar->removeAction(indiceAct);
11610 }
11611 else if (!centralToolBar->actions().contains(indiceAct)) centralToolBar->addAction(indiceAct);
11612 showIndice=!showIndice;
11613 }
11614
TogglePuissance()11615 void Texmaker::TogglePuissance()
11616 {
11617 if (showPuissance)
11618 {
11619 if (centralToolBar->actions().contains(puissanceAct)) centralToolBar->removeAction(puissanceAct);
11620 }
11621 else if (!centralToolBar->actions().contains(puissanceAct)) centralToolBar->addAction(puissanceAct);
11622 showPuissance=!showPuissance;
11623 }
11624
ToggleSmallfrac()11625 void Texmaker::ToggleSmallfrac()
11626 {
11627 if (showSmallfrac)
11628 {
11629 if (centralToolBar->actions().contains(smallfracAct)) centralToolBar->removeAction(smallfracAct);
11630 }
11631 else if (!centralToolBar->actions().contains(smallfracAct)) centralToolBar->addAction(smallfracAct);
11632 showSmallfrac=!showSmallfrac;
11633 }
11634
ToggleDfrac()11635 void Texmaker::ToggleDfrac()
11636 {
11637 if (showDfrac)
11638 {
11639 if (centralToolBar->actions().contains(dfracAct)) centralToolBar->removeAction(dfracAct);
11640 }
11641 else if (!centralToolBar->actions().contains(dfracAct)) centralToolBar->addAction(dfracAct);
11642 showDfrac=!showDfrac;
11643 }
11644
ToggleRacine()11645 void Texmaker::ToggleRacine()
11646 {
11647 if (showRacine)
11648 {
11649 if (centralToolBar->actions().contains(racineAct)) centralToolBar->removeAction(racineAct);
11650 }
11651 else if (!centralToolBar->actions().contains(racineAct)) centralToolBar->addAction(racineAct);
11652 showRacine=!showRacine;
11653 }
11654
splitter2Changed()11655 void Texmaker::splitter2Changed()
11656 {
11657 QFontMetrics fm(qApp->font());
11658 if (OutputTableWidget->isVisible()) OutputTextEdit->setMaximumHeight(5*(fm.lineSpacing()+4));
11659 else
11660 {
11661 if (splitter2->sizes().at(1)>0) OutputTextEdit->setMaximumHeight(splitter2->sizes().at(1));
11662 else OutputTextEdit->setMaximumHeight(splitter2->sizes().at(0));
11663 }
11664 }
11665
SaveSession()11666 void Texmaker::SaveSession()
11667 {
11668 if ( !currentEditorView() ) return;
11669 QString currentDir=QDir::homePath();
11670 if (!lastDocument.isEmpty())
11671 {
11672 QFileInfo fi(lastDocument);
11673 if (fi.exists() && fi.isReadable()) currentDir=fi.absolutePath();
11674 }
11675 QString fn = QFileDialog::getSaveFileName(this,tr("Save"),currentDir,"Texmaker session (*.tks);;All files (*.*)");
11676 if ( !fn.isEmpty() )
11677 {
11678 if (!fn.contains('.')) fn += ".tks";
11679 QFile fic(fn);
11680 if (!fic.open(QIODevice::WriteOnly))
11681 {
11682 QMessageBox::warning( this,tr("Error"),tr("The file could not be saved. Please check if you have write permission."));
11683 return;
11684 }
11685 QDomDocument doc;
11686 QDomProcessingInstruction instr = doc.createProcessingInstruction("xml","version=\"1.0\" encoding=\"UTF-8\"");
11687 doc.appendChild(instr);
11688 QDomElement root=doc.createElement("TexmakerSession");
11689 root.setAttribute("quickmode",QString::number(quickmode));
11690 doc.appendChild(root);
11691 QDomElement element;
11692 FilesMap::Iterator itf;
11693 QString docname;
11694 for( itf = filenames.begin(); itf != filenames.end(); ++itf )
11695 {
11696 docname=filenames[itf.key()];
11697 if (!docname.startsWith("untitled"))
11698 {
11699 element=doc.createElement("document");
11700 element.setAttribute("file",docname);
11701 element.setAttribute("line",QString::number(itf.key()->editor->textCursor().blockNumber()));
11702 element.setAttribute("bookmark1",QString::number(itf.key()->editor->UserBookmark[0]));
11703 element.setAttribute("bookmark2",QString::number(itf.key()->editor->UserBookmark[1]));
11704 element.setAttribute("bookmark3",QString::number(itf.key()->editor->UserBookmark[2]));
11705 if ((!singlemode) && (MasterName==docname)) element.setAttribute("master","true");
11706 else element.setAttribute("master","false");
11707 if (itf.key()==currentEditorView()) element.setAttribute("hasfocus","true");
11708 else element.setAttribute("hasfocus","false");
11709 root.appendChild(element);
11710 }
11711 }
11712
11713 QTextStream out (&fic);
11714 doc.save(out,4);
11715 fic.close();
11716 }
11717 }
11718
LoadSession()11719 void Texmaker::LoadSession()
11720 {
11721 QString currentDir=QDir::homePath();
11722 if (!lastDocument.isEmpty())
11723 {
11724 QFileInfo fi(lastDocument);
11725 if (fi.exists() && fi.isReadable()) currentDir=fi.absolutePath();
11726 }
11727 QString fn = QFileDialog::getOpenFileName(this,tr("Open File"),currentDir,"Texmaker session (*.tks);;All files (*.*)");
11728 if (fn.isEmpty()) return;
11729 LoadSessionFile(fn);
11730 }
11731
LoadSessionFile(const QString & fn)11732 void Texmaker::LoadSessionFile(const QString &fn)
11733 {
11734 QFile fic( fn );
11735 if ( !fic.open( QIODevice::ReadOnly ) )
11736 {
11737 QMessageBox::warning( this,tr("Error"), tr("You do not have read permission to this file."));
11738 return;
11739 }
11740 QDomDocument doc;
11741 if (!doc.setContent(&fic))
11742 {
11743 fic.close();
11744 return;
11745 }
11746 QDomElement root = doc.documentElement();
11747 if (root.tagName() != "TexmakerSession")
11748 {
11749 fic.close();
11750 return;
11751 }
11752 if (root.hasAttribute("quickmode")) quickmode=root.attribute("quickmode").toInt();
11753 QString file, ofile;
11754 int b1, b2, b3, l, ob1, ob2, ob3, ol;
11755 bool ma, oma;
11756 bool fo=false;
11757 QDomElement element = root.firstChildElement();
11758 if (!singlemode) ToggleMode();
11759 while (!element.isNull())
11760 {
11761 b1=0;
11762 b2=0;
11763 b3=0;
11764 l=0;
11765 ma=false;
11766 file="";
11767 if (element.hasAttribute("file"))
11768 {
11769 file=element.attribute("file");
11770 if (element.hasAttribute("line")) l=element.attribute("line").toInt();
11771 if (element.hasAttribute("bookmark1")) b1=element.attribute("bookmark1").toInt();
11772 if (element.hasAttribute("bookmark2")) b2=element.attribute("bookmark2").toInt();
11773 if (element.hasAttribute("bookmark3")) b3=element.attribute("bookmark3").toInt();
11774 if (element.hasAttribute("master")) ma=(element.attribute("master")=="true");
11775 if (element.hasAttribute("hasfocus")) fo=(element.attribute("hasfocus")=="true");
11776 if (fo)
11777 {
11778 ofile=file;
11779 ol=l;
11780 ob1=b1;
11781 ob2=b2;
11782 ob3=b3;
11783 oma=ma;
11784 }
11785 else
11786 {
11787 fileOpenAndGoto(file,l+1,false);
11788 if (currentEditorView() && getName()==file)
11789 {
11790 currentEditorView()->editor->UserBookmark[0]=b1;
11791 currentEditorView()->editor->UserBookmark[1]=b2;
11792 currentEditorView()->editor->UserBookmark[2]=b3;
11793 currentEditorView()->update();
11794 if (singlemode && ma) ToggleMode();
11795 }
11796 }
11797
11798 }
11799 element=element.nextSiblingElement();
11800 }
11801 fic.close();
11802 if (!ofile.isEmpty())
11803 {
11804 fileOpenAndGoto(ofile,l+1,true);
11805 if (currentEditorView() && getName()==ofile)
11806 {
11807 currentEditorView()->editor->UserBookmark[0]=ob1;
11808 currentEditorView()->editor->UserBookmark[1]=ob2;
11809 currentEditorView()->editor->UserBookmark[2]=ob3;
11810 currentEditorView()->update();
11811 if (singlemode && oma) ToggleMode();
11812 }
11813 }
11814 }
11815
SaveLastSession()11816 void Texmaker::SaveLastSession()
11817 {
11818 if ( !currentEditorView() ) return;
11819 QFile fic(sessionTempFile);
11820 if (!fic.open(QIODevice::WriteOnly))
11821 {
11822 return;
11823 }
11824 QDomDocument doc;
11825 QDomProcessingInstruction instr = doc.createProcessingInstruction("xml","version=\"1.0\" encoding=\"UTF-8\"");
11826 doc.appendChild(instr);
11827 QDomElement root=doc.createElement("TexmakerSession");
11828 root.setAttribute("quickmode",QString::number(quickmode));
11829 doc.appendChild(root);
11830 QDomElement element;
11831 FilesMap::Iterator itf;
11832 QString docname;
11833 for( itf = filenames.begin(); itf != filenames.end(); ++itf )
11834 {
11835 docname=filenames[itf.key()];
11836 if (!docname.startsWith("untitled"))
11837 {
11838 element=doc.createElement("document");
11839 element.setAttribute("file",docname);
11840 element.setAttribute("line",QString::number(itf.key()->editor->textCursor().blockNumber()));
11841 element.setAttribute("bookmark1",QString::number(itf.key()->editor->UserBookmark[0]));
11842 element.setAttribute("bookmark2",QString::number(itf.key()->editor->UserBookmark[1]));
11843 element.setAttribute("bookmark3",QString::number(itf.key()->editor->UserBookmark[2]));
11844 if ((!singlemode) && (MasterName==docname)) element.setAttribute("master","true");
11845 else element.setAttribute("master","false");
11846 if (itf.key()==currentEditorView()) element.setAttribute("hasfocus","true");
11847 else element.setAttribute("hasfocus","false");
11848 root.appendChild(element);
11849 }
11850 }
11851
11852 QTextStream out (&fic);
11853 doc.save(out,4);
11854 fic.close();
11855
11856 }
11857
LoadLastSession()11858 void Texmaker::LoadLastSession()
11859 {
11860 QFileInfo fi(sessionTempFile);
11861 if (!fi.exists()) return;
11862 QFile fic( sessionTempFile );
11863 if ( !fic.open( QIODevice::ReadOnly ) )
11864 {
11865 QMessageBox::warning( this,tr("Error"), tr("You do not have read permission to this file."));
11866 return;
11867 }
11868 QDomDocument doc;
11869 if (!doc.setContent(&fic))
11870 {
11871 fic.close();
11872 return;
11873 }
11874 QDomElement root = doc.documentElement();
11875 if (root.tagName() != "TexmakerSession")
11876 {
11877 fic.close();
11878 return;
11879 }
11880 if (root.hasAttribute("quickmode")) quickmode=root.attribute("quickmode").toInt();
11881 QString file, ofile;
11882 int b1, b2, b3, l, ob1, ob2, ob3, ol;
11883 bool ma, oma;
11884 bool fo=false;
11885 QDomElement element = root.firstChildElement();
11886 if (!singlemode) ToggleMode();
11887 while (!element.isNull())
11888 {
11889 b1=0;
11890 b2=0;
11891 b3=0;
11892 l=0;
11893 ma=false;
11894 file="";
11895 if (element.hasAttribute("file"))
11896 {
11897 file=element.attribute("file");
11898 if (element.hasAttribute("line")) l=element.attribute("line").toInt();
11899 if (element.hasAttribute("bookmark1")) b1=element.attribute("bookmark1").toInt();
11900 if (element.hasAttribute("bookmark2")) b2=element.attribute("bookmark2").toInt();
11901 if (element.hasAttribute("bookmark3")) b3=element.attribute("bookmark3").toInt();
11902 if (element.hasAttribute("master")) ma=(element.attribute("master")=="true");
11903 if (element.hasAttribute("hasfocus")) fo=(element.attribute("focus")=="true");
11904 if (fo)
11905 {
11906 ofile=file;
11907 ol=l;
11908 ob1=b1;
11909 ob2=b2;
11910 ob3=b3;
11911 oma=ma;
11912 }
11913 else
11914 {
11915 fileOpenAndGoto(file,l+1,false);
11916 if (currentEditorView() && getName()==file)
11917 {
11918 currentEditorView()->editor->UserBookmark[0]=b1;
11919 currentEditorView()->editor->UserBookmark[1]=b2;
11920 currentEditorView()->editor->UserBookmark[2]=b3;
11921 currentEditorView()->update();
11922 if (singlemode && ma) ToggleMode();
11923 }
11924 }
11925
11926 }
11927 element=element.nextSiblingElement();
11928 }
11929 fic.close();
11930 if (!ofile.isEmpty())
11931 {
11932 fileOpenAndGoto(ofile,l+1,true);
11933 if (currentEditorView() && getName()==ofile)
11934 {
11935 currentEditorView()->editor->UserBookmark[0]=ob1;
11936 currentEditorView()->editor->UserBookmark[1]=ob2;
11937 currentEditorView()->editor->UserBookmark[2]=ob3;
11938 currentEditorView()->update();
11939 if (singlemode && oma) ToggleMode();
11940 }
11941 }
11942 }
11943
copyFile(QString origin,QString destination)11944 bool Texmaker::copyFile(QString origin,QString destination)
11945 {
11946 if (destination.isEmpty() || origin.isEmpty()) return false;
11947 QFileInfo fi_or(origin);
11948 if (!fi_or.exists()) return false;
11949 QFile file_or(origin);
11950 QFileInfo fi_dest(destination);
11951 if (fi_dest.exists())
11952 {
11953 QFile file_dest(destination);
11954 file_dest.remove();
11955 file_or.copy(destination);
11956 }
11957 else
11958 {
11959 file_or.copy(destination);
11960 }
11961 return true;
11962 }
11963
11964 // void Texmaker::removeDir(QDir thedir)
11965 // {
11966 // QString name=thedir.dirName();
11967 // QDirIterator iterator(thedir,QDirIterator::NoIteratorFlags);
11968 // while(iterator.hasNext())
11969 // {
11970 // QString entry(iterator.next());
11971 // if(!QFileInfo(entry).isDir())
11972 // {
11973 // if (QFile::exists(entry))
11974 // {
11975 // QFile file(entry);
11976 // file.open( QIODevice::ReadOnly );
11977 // file.remove();
11978 // }
11979 // }
11980 // }
11981 // thedir.cdUp();
11982 // thedir.rmdir(name);
11983 // }
11984
11985
createBuildSubdirectory(QString fn)11986 void Texmaker::createBuildSubdirectory(QString fn)
11987 {
11988 if (fn.isEmpty() || fn.startsWith("untitled")) return;
11989 QFileInfo fi(fn);
11990 if (!fi.exists()) return;
11991 QDir basedir(fi.absolutePath());
11992 QDir outputdir(fi.absolutePath()+"/build");
11993 if (outputdir.exists()) return;
11994 basedir.mkdir("build");
11995 }
11996
outputName(QString finame,QString extension)11997 QString Texmaker::outputName(QString finame,QString extension)
11998 {
11999 return outputBaseName(finame)+extension;
12000 }
12001
outputBaseName(QString finame)12002 QString Texmaker::outputBaseName(QString finame)
12003 {
12004 QString name="";
12005 QFileInfo fi(finame);
12006 QString path=fi.absolutePath();
12007 QString fn=fi.fileName();
12008 if (useoutputdir) name=path+"/build/"+fn;
12009 else name=fi.absoluteFilePath();
12010 QString ext=fi.suffix();
12011 QString basename=name.left(name.length()-ext.length()-1);
12012 return basename;
12013 }
12014
gtkSession()12015 bool Texmaker::gtkSession()
12016 {
12017 bool result=false;
12018 #if defined(Q_OS_UNIX) && !defined(Q_OS_MAC)
12019 result=true;// 1 : no kde ; 2: kde ; 3 : kde4 ;
12020 QString kdesession= ::getenv("KDE_FULL_SESSION");
12021 QString kdeversion= ::getenv("KDE_SESSION_VERSION");
12022 if (!kdesession.isEmpty()) result=false;
12023 if (!kdeversion.isEmpty()) result=false;
12024 #endif
12025 return result;
12026 }
12027
setMasterDocument(const QString & fn)12028 void Texmaker::setMasterDocument(const QString &fn)
12029 {
12030 if (singlemode && currentEditorView())
12031 {
12032 MasterName=fn;
12033 if (MasterName.startsWith("untitled") || MasterName=="")
12034 {
12035 QMessageBox::warning( this,tr("Error"),tr("Could not start the command.")+"\nno valid name for the master document");
12036 return;
12037 }
12038 QFileInfo fi(MasterName);
12039 if (fi.exists() && fi.isReadable())
12040 {
12041 QString shortName = MasterName;
12042 int pos;
12043 while ( (pos = (int)shortName.indexOf('/')) != -1 ) shortName.remove(0,pos+1);
12044 ToggleAct->setText(tr("Normal Mode (current master document :")+shortName+")");
12045 singlemode=false;
12046 stat1->setText(QString(" %1 ").arg(tr("Master Document :")+shortName));
12047 ToggleDocAct->setEnabled(true);
12048 UpdateStructure();
12049 UpdateBibliography();
12050 }
12051 }
12052 }
12053
compareDocuments()12054 void Texmaker::compareDocuments()
12055 {
12056 if ( !currentEditorView() ) return;
12057 QString code=QString::fromUtf8("<!-- Generated by Texmaker -->\n");
12058 QTextCodec *codec = QTextCodec::codecForName("UTF-8");
12059 QFile templatefile;
12060 templatefile.setFileName(":/diff/checkdiff.txt");
12061 templatefile.open(QIODevice::ReadOnly);
12062 QTextStream t(&templatefile);
12063 t.setCodec(codec);
12064 while (!t.atEnd())
12065 {
12066 code+= t.readLine()+"\n";
12067 }
12068 templatefile.close();
12069 code.replace("#BASE#",currentEditorView()->editor->toPlainText());
12070 code.replace("#NEW#",sourceviewerWidget->editor->toPlainText());
12071
12072 QString tempDir=QDir::tempPath();
12073 QString prefixFile=QDir::homePath();
12074 prefixFile="texmaker_temp_diff_"+prefixFile.section('/',-1);
12075 prefixFile=QString(QUrl::toPercentEncoding(prefixFile));
12076 prefixFile.remove("%");
12077 QString tempFile=tempDir+"/"+prefixFile+".html";
12078
12079 QFile fi_html(tempFile);
12080 if (!fi_html.open(QIODevice::WriteOnly)) return;
12081 QTextStream out (&fi_html);
12082 out.setCodec(codec);
12083 out << code;
12084 fi_html.close();
12085 #ifdef INTERNAL_BROWSER
12086 if (diffWindow)
12087 {
12088 diffWindow->close();
12089 }
12090 diffWindow=new Browser("file:///"+tempFile,false, 0);
12091 diffWindow->raise();
12092 diffWindow->show();
12093 #else
12094 QDesktopServices::openUrl("file:///"+tempFile);
12095 #endif
12096 }
12097