"Fossies" - the Fresh Open Source Software Archive

Member "texmaker-5.0.4/texmaker.cpp" (3 Jan 2020, 432514 Bytes) of package /linux/misc/texmaker-5.0.4.tar.bz2:


As a special service "Fossies" has tried to format the requested source page into HTML format using (guessed) C and C++ source code syntax highlighting (style: standard) with prefixed line numbers and code folding option. Alternatively you can here view or download the uninterpreted source code file. For more information about "texmaker.cpp" see the Fossies "Dox" file reference documentation and the latest Fossies "Diffs" side-by-side code changes report: 5.0.3_vs_5.0.4.

    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 
  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 
  931 Texmaker::~Texmaker(){
  932 if (spellChecker) delete spellChecker;
  933 }
  934 
  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 Act->setShortcut(Qt::CTRL+Qt::Key_Comma);
 2238 connect(Act, SIGNAL(triggered()), this, SLOT(GeneralOptions()));
 2239 optionsMenu->addAction(Act);
 2240 optionsMenu->addSeparator();
 2241 ToggleAct = new QAction(tr("Define Current Document as 'Master Document'"), this);
 2242 ToggleAct->setShortcut(Qt::CTRL+Qt::Key_0);
 2243 connect(ToggleAct, SIGNAL(triggered()), this, SLOT(ToggleMode()));
 2244 optionsMenu->addAction(ToggleAct);
 2245 optionsMenu->addSeparator();
 2246 // appearanceMenu=optionsMenu->addMenu(tr("Interface Appearance"));
 2247 // appearanceGroup = new QActionGroup(this);
 2248 // Act = new QAction("Modern", this);
 2249 // Act->setCheckable(true);
 2250 // connect(Act, SIGNAL(triggered()), this, SLOT(updateAppearance()));
 2251 // appearanceGroup->addAction(Act);
 2252 // if (modern_style) Act->setChecked(true);
 2253 // appearanceMenu->addAction(Act);
 2254 // Act = new QAction("Classic", this);
 2255 // Act->setCheckable(true);
 2256 // connect(Act, SIGNAL(triggered()), this, SLOT(updateAppearance()));
 2257 // appearanceGroup->addAction(Act);
 2258 // if (!modern_style) Act->setChecked(true);
 2259 // appearanceMenu->addAction(Act);
 2260 #if defined(Q_OS_UNIX) && !defined(Q_OS_MAC)
 2261 Act = new QAction(tr("Change Interface Font"), this);
 2262 connect(Act, SIGNAL(triggered()), this, SLOT(SetInterfaceFont()));
 2263 optionsMenu->addAction(Act);
 2264 #endif
 2265 optionsMenu->addSeparator();
 2266 translationMenu=optionsMenu->addMenu(tr("Interface Language"));
 2267 translationGroup = new QActionGroup(this);
 2268 QString currentTranslation=TexmakerApp::instance()->language;
 2269 for (int i=0; i < translationList.count(); i++)
 2270     {
 2271     Act = new QAction(translationList.at(i), this);
 2272     Act->setCheckable(true);
 2273     connect(Act, SIGNAL(triggered()), this, SLOT(updateTranslation()));
 2274     translationGroup->addAction(Act);
 2275     if ((currentTranslation==translationList.at(i)) || (currentTranslation.left(2)==translationList.at(i)) )
 2276         {
 2277         Act->setChecked(true);
 2278         }
 2279     translationMenu->addAction(Act);
 2280     }
 2281 optionsMenu->addSeparator();
 2282 #if defined(Q_OS_MAC)
 2283 settingsMenu=optionsMenu->addMenu(tr("Manage Settings File"));
 2284 #else
 2285 settingsMenu=optionsMenu->addMenu(tr("Settings File"));
 2286 #endif
 2287 Act = new QAction( tr("Reset Settings"), this);
 2288 connect(Act, SIGNAL(triggered()), this, SLOT(DeleteSettings()));
 2289 settingsMenu->addAction(Act);
 2290 Act = new QAction( tr("Save a copy of the settings file"), this);
 2291 connect(Act, SIGNAL(triggered()), this, SLOT(CopySettings()));
 2292 settingsMenu->addAction(Act);
 2293 Act = new QAction( tr("Replace the settings file by a new one"), this);
 2294 connect(Act, SIGNAL(triggered()), this, SLOT(ReplaceSettings()));
 2295 settingsMenu->addAction(Act);
 2296     
 2297 helpMenu = menuBar()->addMenu(tr("&Help"));
 2298 if (gtkEnv) Act = new QAction(QIcon::fromTheme("help-contents", QIcon(":/images/help.png")), tr("LaTeX Reference"), this);
 2299 else Act = new QAction(getIcon(":/images/help.png"), tr("LaTeX Reference"), this);
 2300 connect(Act, SIGNAL(triggered()), this, SLOT(LatexHelp()));
 2301 helpMenu->addAction(Act);
 2302 if (gtkEnv) Act = new QAction(QIcon::fromTheme("help-contents", QIcon(":/images/help.png")), tr("User Manual"), this);
 2303 else Act = new QAction(getIcon(":/images/help.png"), tr("User Manual"), this);
 2304 connect(Act, SIGNAL(triggered()), this, SLOT(UserManualHelp()));
 2305 helpMenu->addAction(Act);
 2306 helpMenu->addSeparator();
 2307 if (gtkEnv) Act = new QAction(QIcon::fromTheme("help-contents", QIcon(":/images/help.png")), "TexDoc [selection]", this);
 2308 else Act = new QAction(getIcon(":/images/help.png"), "TexDoc [selection]", this);
 2309 connect(Act, SIGNAL(triggered()), this, SLOT(TexDocHelp()));
 2310 helpMenu->addAction(Act);
 2311 
 2312 
 2313 // QString locale = QString(QLocale::system().name()).left(2);
 2314 // if (locale=="fr")
 2315 // {
 2316 // if (gtkEnv) Act = new QAction(QIcon::fromTheme("help-contents", QIcon(":/images/help.png")), QString::fromUtf8("Documentation LaTeX/Texmaker en ligne"), this); 
 2317 // else Act = new QAction(getIcon(":/images/help.png"), QString::fromUtf8("Documentation LaTeX/Texmaker en ligne"), this);
 2318 // connect(Act, SIGNAL(triggered()), this, SLOT(Docufrlatex()));
 2319 // helpMenu->addAction(Act);  
 2320 // }
 2321 // else
 2322 // {
 2323 if (gtkEnv) Act = new QAction(QIcon::fromTheme("help-contents", QIcon(":/images/help.png")), QString::fromUtf8("LaTeX wikibook"), this); 
 2324 else Act = new QAction(getIcon(":/images/help.png"), QString::fromUtf8("LaTeX wikibook"), this);
 2325 connect(Act, SIGNAL(triggered()), this, SLOT(Doculatex()));
 2326 helpMenu->addAction(Act);  
 2327 //}  
 2328 
 2329 helpMenu->addSeparator();
 2330 Act = new QAction( tr("Check for Update"), this);
 2331 connect(Act, SIGNAL(triggered()), this, SLOT(CheckVersion()));
 2332 helpMenu->addAction(Act);
 2333 
 2334 helpMenu->addSeparator();
 2335 Act = new QAction(getIcon(":/images/appicon.png"), tr("About Texmaker"), this);
 2336 connect(Act, SIGNAL(triggered()), this, SLOT(HelpAbout()));
 2337 helpMenu->addAction(Act);
 2338 
 2339 
 2340 QList<QAction *> listaction;
 2341 KeysMap::Iterator its;
 2342 bool hasNextPrev=false;
 2343 bool hasQuote=false;
 2344 bool hasTools=false;
 2345 bool hasEdit=false;
 2346 
 2347 if (shortcuts.isEmpty())
 2348     {
 2349     actionstext.clear();
 2350     listaction << toolMenu->actions();
 2351     listaction << editMenu->actions();
 2352     listaction << NextDocAct << PrevDocAct;
 2353     listaction << latex1Menu->actions();
 2354     listaction << latex11Menu->actions();
 2355     listaction << latex12Menu->actions();
 2356     listaction << latex13Menu->actions();
 2357     listaction << latex14Menu->actions();
 2358     listaction << latex15Menu->actions();
 2359     listaction << latex16Menu->actions();
 2360     listaction << latex17Menu->actions();
 2361     listaction << latex18Menu->actions();
 2362     listaction << math1Menu->actions();
 2363     listaction << math11Menu->actions();
 2364     listaction << math12Menu->actions();
 2365     listaction << math13Menu->actions();
 2366     listaction << math14Menu->actions();
 2367     QListIterator<QAction*> iterator(listaction);
 2368     while ( iterator.hasNext() )
 2369         {
 2370         QAction *action = iterator.next();
 2371         if (action && (!action->menu()) && (!action->data().toString().isEmpty())) 
 2372             {
 2373             if (action->shortcut().isEmpty()) shortcuts.insert(action->data().toString(),"none");
 2374             else shortcuts.insert(action->data().toString(),action->shortcut().toString(QKeySequence::PortableText));
 2375             actionstext.insert(action->data().toString(),action->text());
 2376             }
 2377         }
 2378     }
 2379 else 
 2380   {
 2381   for( its = shortcuts.begin(); its != shortcuts.end(); ++its )
 2382       {
 2383       if (its.key()=="Next") hasNextPrev=true;
 2384       if (its.key().contains("\\glqq / \\grqq")) hasQuote=true;
 2385       if (its.key()=="LaTeX") hasTools=true;
 2386       if (its.key()=="Comment") hasEdit=true;
 2387       }
 2388   if (!hasNextPrev) 
 2389       {
 2390       shortcuts.insert(NextDocAct->data().toString(),NextDocAct->shortcut().toString(QKeySequence::PortableText));
 2391       actionstext.insert(NextDocAct->data().toString(),NextDocAct->text());
 2392       shortcuts.insert(PrevDocAct->data().toString(),PrevDocAct->shortcut().toString(QKeySequence::PortableText));
 2393       actionstext.insert(PrevDocAct->data().toString(),PrevDocAct->text());
 2394       }
 2395   if (!hasQuote) 
 2396       {
 2397       shortcuts.insert(latex18Menu->actions().at(0)->data().toString(),latex18Menu->actions().at(0)->shortcut().toString(QKeySequence::PortableText));
 2398       actionstext.insert(latex18Menu->actions().at(0)->data().toString(),latex18Menu->actions().at(0)->text());
 2399       shortcuts.insert(latex18Menu->actions().at(1)->data().toString(),latex18Menu->actions().at(1)->shortcut().toString(QKeySequence::PortableText));
 2400       actionstext.insert(latex18Menu->actions().at(1)->data().toString(),latex18Menu->actions().at(1)->text());
 2401       }
 2402   if (!hasTools) 
 2403       {
 2404     listaction << toolMenu->actions();
 2405     QListIterator<QAction*> iterator(listaction);
 2406     while ( iterator.hasNext() )
 2407         {
 2408         QAction *action = iterator.next();
 2409         if (action && (!action->menu()) && (!action->data().toString().isEmpty())) 
 2410             {
 2411             if (action->shortcut().isEmpty()) shortcuts.insert(action->data().toString(),"none");
 2412             else shortcuts.insert(action->data().toString(),action->shortcut().toString(QKeySequence::PortableText));
 2413             actionstext.insert(action->data().toString(),action->text());
 2414             }
 2415         }
 2416       }
 2417   listaction.clear();
 2418   if (!hasEdit) 
 2419       {
 2420     listaction << editMenu->actions();
 2421     QListIterator<QAction*> iterator(listaction);
 2422     while ( iterator.hasNext() )
 2423         {
 2424         QAction *action = iterator.next();
 2425         if (action && (!action->menu()) && (!action->data().toString().isEmpty())) 
 2426             {
 2427             if (action->shortcut().isEmpty()) shortcuts.insert(action->data().toString(),"none");
 2428             else shortcuts.insert(action->data().toString(),action->shortcut().toString(QKeySequence::PortableText));
 2429             actionstext.insert(action->data().toString(),action->text());
 2430             }
 2431         }
 2432       }
 2433   ModifyShortcuts();
 2434   }
 2435 }
 2436 
 2437 void Texmaker::setupToolBars()
 2438 {
 2439 QAction *Act;
 2440 QStringList list;
 2441 bool gtkEnv=false;
 2442 //bool gtkEnv=gtkSession();
 2443 //file
 2444 fileToolBar = addToolBar("File ToolBar");
 2445 fileToolBar->setObjectName("File");
 2446 fileToolBar->setStyleSheet(Theme::viewportDarkStyleSheet);
 2447 
 2448 if (gtkEnv) Act = new QAction(QIcon::fromTheme("document-new", QIcon(":/images/filenew.png")), tr("New"), this);
 2449 else Act = new QAction(getIcon(":/images/filenew.png"), tr("New"), this);
 2450 connect(Act, SIGNAL(triggered()), this, SLOT(fileNew()));
 2451 fileToolBar->addAction(Act);
 2452 
 2453 if (gtkEnv) Act = new QAction(QIcon::fromTheme("document-open", QIcon(":/images/fileopen.png")), tr("Open"), this);
 2454 else Act = new QAction(getIcon(":/images/fileopen.png"), tr("Open"), this);
 2455 connect(Act, SIGNAL(triggered()), this, SLOT(fileOpen()));
 2456 fileToolBar->addAction(Act);
 2457 
 2458 //Act = new QAction(QIcon(":/images/filesave.png"), tr("Save"), this);
 2459 //connect(Act, SIGNAL(triggered()), this, SLOT(fileSave()));
 2460 fileToolBar->addAction(SaveAct);
 2461 
 2462 //Act = new QAction(QIcon(":/images/fileclose.png"), tr("Close"), this);
 2463 //connect(Act, SIGNAL(triggered()), this, SLOT(fileClose()));
 2464 //fileToolBar->addAction(Act);
 2465 
 2466 //edit
 2467 editToolBar = addToolBar("Edit ToolBar");
 2468 editToolBar->setObjectName("Edit");
 2469 editToolBar->setStyleSheet(Theme::viewportDarkStyleSheet);
 2470 
 2471 //Act = new QAction(QIcon(":/images/undo.png"), tr("Undo"), this);
 2472 //connect(Act, SIGNAL(triggered()), this, SLOT(editUndo()));
 2473 editToolBar->addAction(UndoAct);
 2474 
 2475 //Act = new QAction(QIcon(":/images/redo.png"), tr("Redo"), this);
 2476 //connect(Act, SIGNAL(triggered()), this, SLOT(editRedo()));
 2477 editToolBar->addAction(RedoAct);
 2478 
 2479 //Act = new QAction(QIcon(":/images/editcopy.png"), tr("Copy"), this);
 2480 //connect(Act, SIGNAL(triggered()), this, SLOT(editCopy()));
 2481 editToolBar->addAction(CopyAct);
 2482 
 2483 //Act = new QAction(QIcon(":/images/editcut.png"), tr("Cut"), this);
 2484 //connect(Act, SIGNAL(triggered()), this, SLOT(editCut()));
 2485 editToolBar->addAction(CutAct);
 2486 
 2487 //Act = new QAction(QIcon(":/images/editpaste.png"), tr("Paste"), this);
 2488 //connect(Act, SIGNAL(triggered()), this, SLOT(editPaste()));
 2489 editToolBar->addAction(PasteAct);
 2490 
 2491 //format
 2492 //formatToolBar = addToolBar("Format ToolBar");
 2493 //formatToolBar->setObjectName("Format");
 2494 //insertToolBarBreak(formatToolBar);
 2495 
 2496 
 2497 //tools
 2498 runToolBar = addToolBar("Tools Toolbar");
 2499 runToolBar->setObjectName("Tools");
 2500 runToolBar->setStyleSheet(Theme::viewportDarkStyleSheet);
 2501 
 2502 list.clear();
 2503 list.append(tr("Quick Build"));
 2504 list.append("LaTeX");
 2505 list.append("Dvi->PS");
 2506 list.append("PDFLaTeX");
 2507 list.append("BibTeX");
 2508 list.append("MakeIndex");
 2509 list.append("MPost");
 2510 list.append("PS->PDF");
 2511 list.append("DVI->PDF");
 2512 list.append("Asymptote");
 2513 list.append("LatexMk");
 2514 list.append("R Sweave");
 2515 list.append("XeLaTeX");
 2516 list.append("LuaLaTeX");
 2517 
 2518 for ( int i = 0; i <= 4; i++ ) list.append(QString::number(i+1)+": "+UserToolName[i]);
 2519 
 2520 comboCompil = new QComboBox(runToolBar);
 2521 comboCompil->setSizePolicy(QSizePolicy::Minimum, QSizePolicy::Fixed);
 2522 comboCompil->setStyleSheet(Theme::comboboxDarkStyleSheet);
 2523 comboCompil->addItems(list);
 2524 comboCompil->setCurrentIndex(runIndex);
 2525 connect(runToolBar->addAction(getIcon(":/images/run.png"),tr("Run")), SIGNAL(triggered()), this, SLOT(doCompile()));
 2526 runToolBar->addWidget(comboCompil);
 2527 
 2528 list.clear();
 2529 list.append(tr("View Dvi"));
 2530 list.append(tr("View PS"));
 2531 list.append(tr("View PDF"));
 2532 
 2533 comboView = new QComboBox(runToolBar);
 2534 comboView->setSizePolicy(QSizePolicy::Minimum, QSizePolicy::Fixed);
 2535 comboView->setStyleSheet(Theme::comboboxDarkStyleSheet);
 2536 comboView->addItems(list);
 2537 comboView->setCurrentIndex(viewIndex);
 2538 connect(runToolBar->addAction(getIcon(":/images/run.png"),tr("View")), SIGNAL(triggered()), this, SLOT(doView()));
 2539 runToolBar->addWidget(comboView);
 2540 
 2541 
 2542 
 2543 Act = new QAction(getIcon(":/images/viewlog.png"),tr("View Log"), this);
 2544 connect(Act, SIGNAL(triggered()), this, SLOT(ViewLog()));
 2545 logToolBar->addAction(Act);
 2546 
 2547 Act = new QAction(getIcon(":/images/errornext.png"),tr("Next LaTeX Error"), this);
 2548 connect(Act, SIGNAL(triggered()), this, SLOT(NextError()));
 2549 Act->setShortcut(Qt::ALT+Qt::Key_Down);
 2550 Act->setToolTip("Alt+Down");
 2551 logToolBar->addAction(Act);
 2552 
 2553 Act = new QAction(getIcon(":/images/errorprev.png"),tr("Previous LaTeX Error"), this);
 2554 Act->setShortcut(Qt::ALT+Qt::Key_Up);
 2555 Act->setToolTip("Alt+Up");
 2556 connect(Act, SIGNAL(triggered()), this, SLOT(PreviousError()));
 2557 logToolBar->addAction(Act);
 2558 
 2559 StopAct = new QAction(getIcon(":/images/process-stop.png"),tr("Stop Process"), this);
 2560 connect(StopAct, SIGNAL(triggered()), this, SLOT(stopProcess()));
 2561 logToolBar->addAction(StopAct);
 2562 StopAct->setEnabled(false);
 2563 
 2564 viewMenu->addSeparator();
 2565 viewMenu->addAction(fileToolBar->toggleViewAction());
 2566 viewMenu->addAction(editToolBar->toggleViewAction());
 2567 //viewMenu->addAction(formatToolBar->toggleViewAction());
 2568 viewMenu->addAction(runToolBar->toggleViewAction());
 2569 }
 2570 
 2571 
 2572 void Texmaker::createStatusBar()
 2573 {
 2574 toggleStructureButton=new PlayerButton(statusBar());
 2575 toggleStructureButton->setImages("structure_button");
 2576 connect(toggleStructureButton, SIGNAL( clicked() ), this, SLOT(ToggleStructurePanel() ) );
 2577 statusBar()->addPermanentWidget(toggleStructureButton,0);
 2578 toggleLogButton=new PlayerButton(statusBar());
 2579 toggleLogButton->setImages("log_button");
 2580 connect(toggleLogButton, SIGNAL( clicked() ), this, SLOT(ToggleLogPanel() ) );
 2581 statusBar()->addPermanentWidget(toggleLogButton,0);
 2582 togglePdfButton=new PlayerButton(statusBar());
 2583 togglePdfButton->setImages("pdf_button");
 2584 connect(togglePdfButton, SIGNAL( clicked() ), this, SLOT(TogglePdfPanel() ) );
 2585 statusBar()->addPermanentWidget(togglePdfButton,0);
 2586 toggleSourceButton=new PlayerButton(statusBar());
 2587 toggleSourceButton->setImages("source_button");
 2588 connect(toggleSourceButton, SIGNAL( clicked() ), this, SLOT(ToggleSourcePanel() ) );
 2589 statusBar()->addPermanentWidget(toggleSourceButton,0);
 2590 
 2591 if (embedinternalpdf && builtinpdfview) togglePdfButton->show();
 2592 else togglePdfButton->hide();
 2593 
 2594 stat2=new DropShadowLabel("Ready",statusBar());
 2595 stat2->setColor(Theme::grayColor);
 2596 stat2->setDropShadowColor(QColor("#000000"));
 2597 stat2->setStyleSheet(Theme::labelStyleSheet);
 2598 statusBar()->addPermanentWidget(stat2,0);
 2599 
 2600 statusBar()->addPermanentWidget(new QLabel(),1);
 2601 
 2602 stat1=new DropShadowLabel("",statusBar());
 2603 stat1->setColor(Theme::grayColor);
 2604 stat1->setDropShadowColor(QColor("#000000"));
 2605 stat1->setStyleSheet(Theme::labelStyleSheet);
 2606 
 2607 stat3=new DropShadowLabel("",statusBar());
 2608 stat3->setColor(Theme::grayColor);
 2609 stat3->setDropShadowColor(QColor("#000000"));
 2610 stat3->setStyleSheet(Theme::labelStyleSheet);
 2611 
 2612 
 2613 statusBar()->addPermanentWidget(stat3,0);
 2614 statusBar()->addPermanentWidget(stat1,0);
 2615 statusBar()->setAutoFillBackground( true );
 2616 QPalette pal( palette() );
 2617 pal.setColor( QPalette::Active, QPalette::WindowText,Theme::grayColor );
 2618 pal.setColor( QPalette::Inactive, QPalette::WindowText, Theme::grayColor );
 2619 pal.setColor( QPalette::Disabled, QPalette::WindowText, Theme::grayColor );
 2620 pal.setColor( QPalette::Active, QPalette::HighlightedText, Theme::grayColor );
 2621 pal.setColor( QPalette::Inactive, QPalette::HighlightedText, Theme::grayColor );
 2622 pal.setColor( QPalette::Disabled, QPalette::HighlightedText,Theme::grayColor );
 2623 pal.setColor( QPalette::Active, QPalette::Base, Theme::grayColor );
 2624 pal.setColor( QPalette::Inactive, QPalette::Base, Theme::grayColor );
 2625 pal.setColor( QPalette::Disabled, QPalette::Base, Theme::grayColor);
 2626 pal.setColor(QPalette::Background, Theme::lightbackgroundColor);
 2627 statusBar()->setPalette( pal );
 2628 //statusBar()->setStyleSheet("QWidget {background-color:#6F6F6F;}");
 2629 
 2630 toggleStructureButton->setEnabled(showstructview);
 2631 toggleLogButton->setEnabled(showoutputview);
 2632 togglePdfButton->setEnabled(showpdfview);
 2633 toggleSourceButton->setEnabled(showsourceview);
 2634 }
 2635 
 2636 void Texmaker::UpdateCaption()
 2637 {
 2638 QString title;
 2639 if   ( !currentEditorView() )   {title="Texmaker";}
 2640 else
 2641     {
 2642     title="Document : "+getName();
 2643     //input_encoding=currentEditorView()->editor->getEncoding();
 2644     }
 2645 setWindowTitle(title);
 2646 //UpdateStructure();
 2647 if (singlemode)
 2648     {
 2649     OutputTextEdit->clear();
 2650     OutputTableWidget->hide();
 2651     if (splitter2->sizes().at(1)>0) OutputTextEdit->setMaximumHeight(splitter2->sizes().at(1));
 2652     separatorline->hide();
 2653     logpresent=false;
 2654     }
 2655 QString finame=getName();
 2656 int check=comboFiles->findData(finame,Qt::UserRole,Qt::MatchExactly | Qt::MatchCaseSensitive);
 2657 comboFiles->setCurrentIndex(check);
 2658 if ((check>-1) && (check<OpenedFilesListWidget->count())) OpenedFilesListWidget->setCurrentRow(check);
 2659 if (!finame.startsWith("untitled") && finame!="") 
 2660   {
 2661   lastDocument=finame;
 2662   }
 2663 if   (currentEditorView())
 2664   {
 2665    SaveAct->setEnabled(currentEditorView()->editor->document()->isModified());
 2666    UndoAct->setEnabled(currentEditorView()->editor->document()->isUndoAvailable());
 2667    RedoAct->setEnabled(currentEditorView()->editor->document()->isRedoAvailable());
 2668    CopyAct->setEnabled(currentEditorView()->editor->textCursor().hasSelection());
 2669    CutAct->setEnabled(currentEditorView()->editor->textCursor().hasSelection());
 2670    stat3->setText(QString(" %1 ").arg(currentEditorView()->editor->getEncoding()));
 2671   }
 2672 else
 2673   {
 2674    SaveAct->setEnabled(false);
 2675    UndoAct->setEnabled(false);
 2676    RedoAct->setEnabled(false);
 2677    CopyAct->setEnabled(false);
 2678    CutAct->setEnabled(false);
 2679    stat3->setText(QString(" %1 ").arg(input_encoding));
 2680   }
 2681 if (currentEditorView()) 
 2682   {
 2683   currentEditorView()->editor->setFocus();
 2684   showCursorPos(currentEditorView()->editor->textCursor().blockNumber() + 1,currentEditorView()->editor->textCursor().position() - currentEditorView()->editor->textCursor().block().position()+1);
 2685 //  showCursorPos(currentEditorView()->editor->textCursor().blockNumber() + 1,currentEditorView()->editor->textCursor().position() - currentEditorView()->editor->document()->findBlock(currentEditorView()->editor->textCursor().selectionStart()).position());
 2686   }
 2687 else posLabel->setText("L: C: ");
 2688 }
 2689 
 2690 void Texmaker::NewDocumentStatus(bool m)
 2691 {
 2692 if ( !currentEditorView() ) return;
 2693 QString finame=getName();
 2694 int check=comboFiles->findData(finame,Qt::UserRole,Qt::MatchExactly | Qt::MatchCaseSensitive);
 2695 if ((check>-1) && (check<OpenedFilesListWidget->count())) OpenedFilesListWidget->setCurrentRow(check);
 2696 if (m)
 2697     {
 2698     //EditorView->setTabIcon(EditorView->indexOf(currentEditorView()),getIcon(":/images/modified.png"));
 2699     //EditorView->setTabText(EditorView->indexOf(currentEditorView()),QFileInfo( getName() ).fileName());
 2700     comboFiles->setItemIcon(comboFiles->findData(finame,Qt::UserRole,Qt::MatchExactly | Qt::MatchCaseSensitive),getIcon(":/images/modified.png"));
 2701     if ((check>-1) && (check<OpenedFilesListWidget->count())) OpenedFilesListWidget->item(check)->setIcon(getIcon(":/images/modified.png"));
 2702     SaveAct->setEnabled(true);
 2703     }
 2704 else
 2705     {
 2706     //EditorView->setTabIcon(EditorView->indexOf(currentEditorView()),getIcon(":/images/empty.png"));
 2707     //EditorView->setTabText(EditorView->indexOf(currentEditorView()),QFileInfo( getName() ).fileName());
 2708     currentEditorView()->editor->updateRevisions();
 2709     comboFiles->setItemIcon(comboFiles->findData(finame,Qt::UserRole,Qt::MatchExactly | Qt::MatchCaseSensitive),QIcon(":/images/empty.png"));
 2710     if ((check>-1) && (check<OpenedFilesListWidget->count())) OpenedFilesListWidget->item(check)->setIcon(QIcon(":/images/empty.png"));
 2711     SaveAct->setEnabled(false);
 2712     }
 2713 }
 2714 
 2715 LatexEditorView *Texmaker::currentEditorView() const
 2716 {
 2717 if ( EditorView->currentWidget() && EditorView->currentWidget()->inherits( "LatexEditorView" ) ) return (LatexEditorView*)EditorView->currentWidget();
 2718 return 0;
 2719 }
 2720 
 2721 QString Texmaker::getName()
 2722 {
 2723 QString title;
 2724 if ( !currentEditorView() ) {title="";}
 2725 else {title=filenames[currentEditorView()];}
 2726 return title;
 2727 }
 2728 
 2729 bool Texmaker::FileAlreadyOpen(QString f)
 2730 {
 2731 bool rep=false;
 2732 FilesMap::Iterator it;
 2733 QString fw32,funix,forig, canorig, can;
 2734 canorig=QFileInfo(f).canonicalFilePath();
 2735 for( it = filenames.begin(); it != filenames.end(); ++it )
 2736     {
 2737     forig=filenames[it.key()];
 2738     fw32=filenames[it.key()];
 2739     funix=filenames[it.key()];
 2740     fw32.replace(QString("\\"),QString("/"));
 2741     funix.replace(QString("/"),QString("\\"));
 2742     can=QFileInfo(filenames[it.key()]).canonicalFilePath();
 2743     if ( (forig==f) || (fw32==f) || (funix==f) || (canorig==can)) 
 2744         {
 2745         EditorView->setCurrentIndex(EditorView->indexOf(it.key()));
 2746         rep=true;
 2747         }
 2748     }
 2749 return rep;
 2750 }
 2751 
 2752 void Texmaker::ComboFilesInsert(const QString & file)
 2753 {
 2754 int index;
 2755 QString fname = QFileInfo( file ).fileName();
 2756 
 2757 for (index=0; index<comboFiles->count(); index++)
 2758     if (comboFiles->itemText(index).localeAwareCompare(fname) > 0) break;
 2759 
 2760 comboFiles->insertItem(index, fname, file);
 2761 comboFiles->setItemIcon(index,QIcon(":/images/empty.png"));
 2762 OpenedFilesListWidget->insertItem(index,fname);
 2763 OpenedFilesListWidget->item(index)->setIcon(QIcon(":/images/empty.png"));
 2764 }
 2765 ///////////////////FILE//////////////////////////////////////
 2766 void Texmaker::load( const QString &f )
 2767 {
 2768 if (FileAlreadyOpen(f) || !QFile::exists( f )) return;
 2769 QFileInfo fi(f);
 2770 if  (fi.suffix()=="tks") 
 2771   {
 2772   LoadSessionFile(f);
 2773   return;
 2774   }
 2775 
 2776 QFile file( f );
 2777 if ( !file.open( QIODevice::ReadOnly ) )
 2778     {
 2779     QMessageBox::warning( this,tr("Error"), tr("You do not have read permission to this file."));
 2780     return;
 2781     }
 2782 bool hasDecodingError=false;
 2783 QByteArray peekBytes(file.peek(1024));
 2784 QByteArray buf = file.readAll();
 2785 
 2786 int bytesRead = buf.size();
 2787 file.close();
 2788 
 2789 QTextCodec* detected_codec;
 2790 QTextCodec* codec = QTextCodec::codecForName(input_encoding.toLatin1());
 2791 if(!codec) codec = QTextCodec::codecForLocale();
 2792 
 2793 QRegExp reEnc("% *!TEX +encoding *= *([^\\r\\n\\x2029]+)[\\r\\n\\x2029]", Qt::CaseInsensitive);
 2794 int pos = reEnc.indexIn(codec->toUnicode(peekBytes));
 2795 if (pos > -1) 
 2796   {
 2797   QString reqName = reEnc.cap(1).trimmed();
 2798   codec = QTextCodec::codecForName(reqName.toLatin1());
 2799   if(!codec) codec = QTextCodec::codecForLocale();
 2800   input_encoding=codec->name();
 2801   }
 2802 
 2803 
 2804 QString text = codec->toUnicode(buf);
 2805 QByteArray verifyBuf = codec->fromUnicode(text);
 2806 QString new_encoding="";
 2807 
 2808 // unicode detection
 2809 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))) 
 2810     {
 2811       detected_codec = QTextCodec::codecForName("UTF-32");
 2812       if (detected_codec) new_encoding=detected_codec->name();
 2813     } 
 2814 else if (bytesRead >= 2 && ((uchar(buf[0]) == 0xff && uchar(buf[1]) == 0xfe) || (uchar(buf[0]) == 0xfe && uchar(buf[1]) == 0xff))) 
 2815     {
 2816       detected_codec = QTextCodec::codecForName("UTF-16");
 2817       if (detected_codec) new_encoding=detected_codec->name();
 2818 
 2819     } 
 2820 else if (bytesRead >= 3 && uchar(buf[0]) == 0xef && uchar(buf[1]) == 0xbb && uchar(buf[2])== 0xbf) 
 2821     {
 2822       detected_codec = QTextCodec::codecForName("UTF-8");
 2823       if (detected_codec) new_encoding=detected_codec->name();
 2824     }
 2825 else
 2826 {
 2827 const char *    data= buf.constData();
 2828 int length=buf.size();
 2829 bool canbeutf8=true;
 2830 static const unsigned char highest1Bits = 0x80;
 2831 static const unsigned char highest2Bits = 0xC0;
 2832 static const unsigned char highest3Bits = 0xE0;
 2833 static const unsigned char highest4Bits = 0xF0;
 2834 static const unsigned char highest5Bits = 0xF8;
 2835 int multiByte=0;
 2836 for (int i=0; i<length; ++i)
 2837   {
 2838       unsigned char c = data[i];
 2839 
 2840       if (multiByte>0)
 2841       {
 2842       if ((c & highest2Bits) == 0x80)
 2843       {
 2844           --(multiByte);
 2845           continue;
 2846       }
 2847       canbeutf8=false;
 2848       break;
 2849       }
 2850 
 2851       // most significant bit zero, single char
 2852       if ((c & highest1Bits) == 0x00)
 2853       continue;
 2854 
 2855       // 110xxxxx => init 1 following bytes
 2856       if ((c & highest3Bits) == 0xC0)
 2857       {
 2858       multiByte = 1;
 2859       continue;
 2860       }
 2861 
 2862       // 1110xxxx => init 2 following bytes
 2863       if ((c & highest4Bits) == 0xE0)
 2864       {
 2865       multiByte = 2;
 2866       continue;
 2867       }
 2868 
 2869       // 11110xxx => init 3 following bytes
 2870       if ((c & highest5Bits) == 0xF0)
 2871       {
 2872       multiByte = 3;
 2873       continue;
 2874       }
 2875     canbeutf8=false;
 2876       break;
 2877   }
 2878 if (canbeutf8) 
 2879       {
 2880       detected_codec = QTextCodec::codecForName("UTF-8");
 2881       if (detected_codec) new_encoding=detected_codec->name();
 2882       }
 2883  }  
 2884 
 2885 if (new_encoding!="")
 2886   {
 2887     if (new_encoding!=codec->name()) hasDecodingError=true;
 2888   }
 2889 else
 2890   {  
 2891   // no unicode
 2892    int minSize = qMin(verifyBuf.size(), buf.size());
 2893   hasDecodingError = (minSize < buf.size()- 4 || memcmp(verifyBuf.constData() + verifyBuf.size() - minSize,buf.constData() + buf.size() - minSize, minSize));
 2894   QEncodingProber prober (QEncodingProber::Universal);
 2895   if (hasDecodingError)
 2896     {
 2897     prober.feed (buf.constData());
 2898     if (prober.confidence() > 0.6) //Kencodingprober works very bad with tex documents
 2899       {
 2900       detected_codec = QTextCodec::codecForName(prober.encoding());
 2901       if (detected_codec) new_encoding=detected_codec->name();
 2902       else if (input_encoding=="UTF-8") new_encoding="ISO-8859-1";
 2903       else if (input_encoding=="ISO-8859-1") new_encoding="UTF-8";
 2904       else new_encoding=QString(QTextCodec::codecForLocale()->name());
 2905       }
 2906     else if (input_encoding=="UTF-8") new_encoding="ISO-8859-1";
 2907     else if (input_encoding=="ISO-8859-1") new_encoding="UTF-8";
 2908     else new_encoding=QString(QTextCodec::codecForLocale()->name());
 2909     }
 2910 
 2911   }
 2912 
 2913 
 2914   
 2915 if (hasDecodingError)
 2916   {
 2917   EncodingDialog *encDlg = new EncodingDialog(this);
 2918   encDlg->ui.comboBoxEncoding->setCurrentIndex(encDlg->ui.comboBoxEncoding->findText(new_encoding, Qt::MatchExactly));
 2919   encDlg->ui.label->setText(encDlg->ui.label->text()+ " ("+input_encoding+").");
 2920   if (encDlg->exec())
 2921       {
 2922       new_encoding=encDlg->ui.comboBoxEncoding->currentText();
 2923       codec = QTextCodec::codecForName(new_encoding.toLatin1());
 2924       text = codec->toUnicode(buf);
 2925       }
 2926   else return;
 2927   }
 2928 
 2929 #if defined(Q_OS_UNIX) && !defined(Q_OS_MAC)
 2930 
 2931 #ifdef USB_VERSION
 2932 QString dicDir=QCoreApplication::applicationDirPath() + "/";
 2933 #else
 2934 #ifdef DEBIAN_SPELLDIR
 2935 QString dicDir=PREFIX"/share/hunspell/dicts/";
 2936 #else
 2937 QString dicDir=PREFIX"/share/texmaker/";
 2938 #endif
 2939 #endif
 2940 
 2941 #endif
 2942 #if defined(Q_OS_MAC)
 2943 QString dicDir=QCoreApplication::applicationDirPath() + "/../Resources/";
 2944 #endif
 2945 #if defined(Q_OS_WIN32)
 2946 QString dicDir=QCoreApplication::applicationDirPath() + "/";
 2947 #endif
 2948 QRegExp reSpell("% *!TEX +spellcheck *= *([^\\r\\n\\x2029]+)[\\r\\n\\x2029]", Qt::CaseInsensitive);
 2949 pos = reSpell.indexIn(codec->toUnicode(peekBytes));
 2950 if (pos > -1) 
 2951   {
 2952   QString lang = dicDir+reSpell.cap(1).trimmed();
 2953   if (spellChecker) delete spellChecker;
 2954   QString affdic=lang+".aff";
 2955   QString spelldic=lang+".dic";
 2956   QFileInfo fidic(spelldic);
 2957   QFileInfo fiaff(affdic);
 2958   if (fidic.exists() && fidic.isReadable() && fiaff.exists() && fiaff.isReadable())
 2959       {
 2960       spellChecker = new Hunspell(lang.toLatin1()+".aff",lang.toLatin1()+".dic");
 2961       }
 2962   else spellChecker=0;
 2963   }  
 2964   
 2965 LatexEditorView *edit = new LatexEditorView(0,EditorFont,svnEnable,showline,edcolors(),hicolors(),inlinespellcheck,spell_ignored_words,spellChecker,tabspaces,tabwidth,QKeySequence(keyToggleFocus),f,userTagsList);
 2966 EditorView->addWidget( edit);
 2967 ComboFilesInsert(f);
 2968 disconnect(EditorView, SIGNAL( currentChanged( int ) ), this, SLOT(UpdateStructure()) );
 2969 EditorView->setCurrentIndex(EditorView->indexOf(edit));
 2970 connect(EditorView, SIGNAL( currentChanged( int ) ), this, SLOT(UpdateStructure()) );
 2971 edit->editor->setReadOnly(false);
 2972 if (hasDecodingError) edit->editor->setEncoding(new_encoding);
 2973 else edit->editor->setEncoding(input_encoding);
 2974 initCompleter();
 2975 if (completion) edit->editor->setCompleter(completer);
 2976 else edit->editor->setCompleter(0);
 2977 edit->editor->setPlainText(text);
 2978 filenames.remove( edit);
 2979 filenames.insert( edit, f );
 2980 
 2981 edit->editor->resetRevisions();
 2982 if(svnEnable) 
 2983 {
 2984 connect(new SvnHelper(f,svnPath), SIGNAL(uncommittedLines(QList<int>)),edit->editor , SLOT(setUncommittedLines(QList<int>)));
 2985 edit->editor->viewport()->update();
 2986 }
 2987 
 2988 edit->editor->document()->setModified(false);
 2989 connect(edit->editor->document(), SIGNAL(modificationChanged(bool)), this, SLOT(NewDocumentStatus(bool)));
 2990 connect(edit->editor, SIGNAL(spellme()), this, SLOT(editSpell()));
 2991 connect(edit->editor, SIGNAL(tooltiptab()), this, SLOT(editTipTab()));
 2992 connect(edit->editor, SIGNAL(requestpdf(int)),this, SLOT(jumpToPdfline(int)));
 2993 connect(edit->editor, SIGNAL(requestUpdateStructure()), this, SLOT(UpdateStructure()));
 2994 currentEditorView()->editor->setLastNumLines(currentEditorView()->editor->numoflines());
 2995 connect(edit->editor, SIGNAL(numLinesChanged(int)), this, SLOT(refreshAllFromCursor(int)));
 2996 connect(edit->editor->document(), SIGNAL(undoAvailable(bool)),UndoAct, SLOT(setEnabled(bool)));
 2997 connect(edit->editor->document(), SIGNAL(redoAvailable(bool)),RedoAct, SLOT(setEnabled(bool)));
 2998 connect(edit->editor, SIGNAL(copyAvailable(bool)), CutAct, SLOT(setEnabled(bool)));
 2999 connect(edit->editor, SIGNAL(copyAvailable(bool)), CopyAct, SLOT(setEnabled(bool)));
 3000 connect(edit->editor, SIGNAL(requestGotoStructure(int)),this, SLOT(jumpToStructure(int)));
 3001 connect(edit->editor, SIGNAL(poshaschanged(int,int)),this, SLOT(showCursorPos(int,int)));
 3002 
 3003 if (wordwrap) {edit->editor->setWordWrapMode(QTextOption::WordWrap);}
 3004 else {edit->editor->setWordWrapMode(QTextOption::NoWrap);}
 3005 
 3006 
 3007 
 3008 UpdateCaption();
 3009 NewDocumentStatus(false);
 3010 AddRecentFile(f);
 3011 ShowStructure();
 3012 UpdateStructure();
 3013 UpdateBibliography();
 3014 
 3015 QString rootName,rootFilePath;
 3016 QTextCursor curs(edit->editor->document());
 3017 curs.movePosition(QTextCursor::NextCharacter, QTextCursor::KeepAnchor,1024);
 3018 QString peekStr = curs.selectedText();
 3019 QRegExp re("% *!TEX +root *= *([^\\x2029]+)\\x2029", Qt::CaseInsensitive);
 3020 pos = re.indexIn(peekStr);
 3021 if (pos > -1) 
 3022   {
 3023   rootName = re.cap(1).trimmed();
 3024   QFileInfo rootFileInfo(fi.canonicalPath() + "/" + rootName);
 3025   if (rootFileInfo.exists()) rootFilePath = rootFileInfo.canonicalFilePath();
 3026   else rootFilePath = rootFileInfo.filePath();
 3027   setMasterDocument(rootFilePath);
 3028   }
 3029 
 3030 
 3031 
 3032 
 3033 #if !defined(Q_OS_MAC)
 3034 show();
 3035 if (windowState()==Qt::WindowMinimized) setWindowState(windowState() & ~Qt::WindowMinimized | Qt::WindowActive);
 3036 qApp->setActiveWindow(this);
 3037 activateWindow();
 3038 setFocus();
 3039 //raise();
 3040 //#ifdef Q_WS_WIN
 3041 //        if (IsIconic (this->winId())) ShowWindow(this->winId(), SW_RESTORE);
 3042 //#endif
 3043 #endif
 3044 if (winmaximized) setWindowState(windowState() & Qt::WindowMaximized | Qt::WindowActive);
 3045 edit->editor->setFocus();
 3046 }
 3047 
 3048 void Texmaker::setLine( const QString &line )
 3049 {
 3050 bool ok;
 3051 int l=line.toInt(&ok,10);
 3052 if (currentEditorView() && ok)
 3053     {
 3054     QTextCursor cur=currentEditorView()->editor->textCursor();
 3055     cur.movePosition(QTextCursor::End);
 3056     currentEditorView()->editor->setTextCursor(cur);
 3057     currentEditorView()->editor->gotoLine(l-1);
 3058     currentEditorView()->editor->setFocus();
 3059     }
 3060 }
 3061 
 3062 void Texmaker::insertFromCommandLine(const QString &entity)
 3063 {
 3064 if (currentEditorView())
 3065     {
 3066     currentEditorView()->editor->insertPlainText(entity);
 3067     #if !defined(Q_OS_MAC)
 3068     show();
 3069     if (windowState()==Qt::WindowMinimized) setWindowState(windowState() & ~Qt::WindowMinimized | Qt::WindowActive);
 3070     qApp->setActiveWindow(this);
 3071     activateWindow();
 3072     setFocus();
 3073     #endif
 3074     if (winmaximized) setWindowState(windowState() & Qt::WindowMaximized | Qt::WindowActive);
 3075     currentEditorView()->editor->setFocus();
 3076     }
 3077 }
 3078 
 3079 void Texmaker::fileNew()
 3080 {
 3081 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);
 3082 edit->editor->setReadOnly(false);
 3083 edit->editor->setEncoding(input_encoding);
 3084 initCompleter();
 3085 if (completion) edit->editor->setCompleter(completer);
 3086 else edit->editor->setCompleter(0);
 3087 EditorView->addWidget( edit);
 3088 EditorView->setCurrentIndex(EditorView->indexOf(edit));
 3089 if (wordwrap) {edit->editor->setWordWrapMode(QTextOption::WordWrap);}
 3090 else {edit->editor->setWordWrapMode(QTextOption::NoWrap);}
 3091 filenames.remove( edit);
 3092 filenames.insert( edit, "untitled"+QString::number(untitled_id) );
 3093 ComboFilesInsert("untitled"+QString::number(untitled_id));
 3094 untitled_id++;
 3095 edit->editor->document()->setModified(false);
 3096 connect(edit->editor->document(), SIGNAL(modificationChanged(bool)), this, SLOT(NewDocumentStatus(bool)));
 3097 connect(edit->editor, SIGNAL(spellme()), this, SLOT(editSpell()));
 3098 connect(edit->editor, SIGNAL(tooltiptab()), this, SLOT(editTipTab()));
 3099 connect(edit->editor, SIGNAL(requestUpdateStructure()), this, SLOT(UpdateStructure()));
 3100 connect(edit->editor, SIGNAL(requestpdf(int)),this, SLOT(jumpToPdfline(int)));
 3101 currentEditorView()->editor->setLastNumLines(currentEditorView()->editor->numoflines());
 3102 connect(edit->editor, SIGNAL(numLinesChanged(int)), this, SLOT(refreshAllFromCursor(int)));
 3103 connect(edit->editor->document(), SIGNAL(undoAvailable(bool)),UndoAct, SLOT(setEnabled(bool)));
 3104 connect(edit->editor->document(), SIGNAL(redoAvailable(bool)),RedoAct, SLOT(setEnabled(bool)));
 3105 connect(edit->editor, SIGNAL(copyAvailable(bool)), CutAct, SLOT(setEnabled(bool)));
 3106 connect(edit->editor, SIGNAL(copyAvailable(bool)), CopyAct, SLOT(setEnabled(bool)));
 3107 connect(edit->editor, SIGNAL(requestGotoStructure(int)),this, SLOT(jumpToStructure(int)));
 3108 connect(edit->editor, SIGNAL(poshaschanged(int,int)),this, SLOT(showCursorPos(int,int)));
 3109 UpdateCaption();
 3110 NewDocumentStatus(false);
 3111 edit->editor->setFocus();
 3112 }
 3113 
 3114 void Texmaker::fileNewFromFile()
 3115 {
 3116 QString currentDir=QDir::homePath();
 3117 if (!lastTemplate.isEmpty())
 3118     {
 3119     QFileInfo fi(lastTemplate);
 3120     if (fi.exists() && fi.isReadable()) currentDir=fi.absolutePath();
 3121     }
 3122 QString fn = QFileDialog::getOpenFileName(this,tr("Open File"),currentDir,"TeX files (*.tex *.bib *.sty *.cls *.mp *.Rnw *.asy);;All files (*.*)");
 3123 if (fn.isEmpty()) return;
 3124 QFile file( fn );
 3125 if ( !file.open( QIODevice::ReadOnly ) )
 3126     {
 3127     QMessageBox::warning( this,tr("Error"), tr("You do not have read permission to this file."));
 3128     return;
 3129     }
 3130 lastTemplate=fn;
 3131 LatexEditorView *edit = new LatexEditorView(0,EditorFont,svnEnable,showline,edcolors(),hicolors(),inlinespellcheck,spell_ignored_words,spellChecker,tabspaces,tabwidth,QKeySequence(keyToggleFocus),fn,userTagsList);
 3132 edit->editor->setReadOnly(false);
 3133 edit->editor->setEncoding(input_encoding);
 3134 initCompleter();
 3135 if (completion) edit->editor->setCompleter(completer);
 3136 else edit->editor->setCompleter(0);
 3137 EditorView->addWidget( edit);
 3138 EditorView->setCurrentIndex(EditorView->indexOf(edit));
 3139 if (wordwrap) {edit->editor->setWordWrapMode(QTextOption::WordWrap);}
 3140 else {edit->editor->setWordWrapMode(QTextOption::NoWrap);}
 3141 filenames.remove( edit);
 3142 filenames.insert( edit, "untitled"+QString::number(untitled_id));
 3143 ComboFilesInsert("untitled"+QString::number(untitled_id));
 3144 untitled_id++;
 3145 QTextStream ts( &file );
 3146 QTextCodec* codec = QTextCodec::codecForName(input_encoding.toLatin1());
 3147 if(!codec) codec = QTextCodec::codecForLocale();
 3148 ts.setCodec(codec);
 3149 edit->editor->setPlainText( ts.readAll() );
 3150 file.close();
 3151 edit->editor->document()->setModified(true);
 3152 connect(edit->editor->document(), SIGNAL(modificationChanged(bool)), this, SLOT(NewDocumentStatus(bool)));
 3153 connect(edit->editor, SIGNAL(spellme()), this, SLOT(editSpell()));
 3154 connect(edit->editor, SIGNAL(tooltiptab()), this, SLOT(editTipTab()));
 3155 currentEditorView()->editor->setLastNumLines(currentEditorView()->editor->numoflines());
 3156 connect(edit->editor, SIGNAL(numLinesChanged(int)), this, SLOT(refreshAllFromCursor(int)));
 3157 connect(edit->editor, SIGNAL(requestpdf(int)),this, SLOT(jumpToPdfline(int)));
 3158 connect(edit->editor, SIGNAL(requestUpdateStructure()), this, SLOT(UpdateStructure()));
 3159 connect(edit->editor->document(), SIGNAL(undoAvailable(bool)),UndoAct, SLOT(setEnabled(bool)));
 3160 connect(edit->editor->document(), SIGNAL(redoAvailable(bool)),RedoAct, SLOT(setEnabled(bool)));
 3161 connect(edit->editor, SIGNAL(copyAvailable(bool)), CutAct, SLOT(setEnabled(bool)));
 3162 connect(edit->editor, SIGNAL(copyAvailable(bool)), CopyAct, SLOT(setEnabled(bool)));
 3163 connect(edit->editor, SIGNAL(requestGotoStructure(int)),this, SLOT(jumpToStructure(int)));
 3164 connect(edit->editor, SIGNAL(poshaschanged(int,int)),this, SLOT(showCursorPos(int,int)));
 3165 
 3166 UpdateCaption();
 3167 NewDocumentStatus(true);
 3168 UpdateStructure();
 3169 UpdateBibliography();
 3170 edit->editor->setFocus();
 3171 }
 3172 
 3173 void Texmaker::fileOpen()
 3174 {
 3175 QString currentDir=QDir::homePath();
 3176 if (!lastDocument.isEmpty())
 3177     {
 3178     QFileInfo fi(lastDocument);
 3179     if (fi.exists() && fi.isReadable()) currentDir=fi.absolutePath();
 3180     }
 3181 QStringList filesNames = QFileDialog::getOpenFileNames(this,tr("Open File"),currentDir,"TeX files (*.tex *.bib *.sty *.cls *.mp *.Rnw *.asy);;All files (*.*)");
 3182 foreach (const QString& fn, filesNames)
 3183   {
 3184   if ( !fn.isEmpty() ) load( fn );
 3185   }
 3186 if ((filesNames.count()==1) && embedinternalpdf && builtinpdfview && showpdfview)
 3187   {
 3188   if ( !currentEditorView() || !singlemode ) return;
 3189   QString finame=getName();
 3190   QFileInfo fi(finame);
 3191   QString basename=fi.completeBaseName();
 3192   QString pdfname=outputName(finame,".pdf");
 3193   QFileInfo pdfi(pdfname);
 3194   if (pdfi.exists() && pdfi.isReadable()) 
 3195     {
 3196       if (pdfviewerWidget)
 3197     {
 3198     pdfviewerWidget->openFile(outputName(finame,".pdf"),viewpdf_command,ghostscript_command);
 3199     StackedViewers->setCurrentWidget(pdfviewerWidget);
 3200     
 3201     //pdfviewerWidget->raise();
 3202     pdfviewerWidget->show();
 3203     }
 3204       else
 3205     {
 3206     //    pdfviewerWidget=new PdfViewer(outputName(finame,".pdf"),viewpdf_command, this);
 3207     pdfviewerWidget=new PdfViewerWidget(outputName(finame,".pdf"),viewpdf_command,ghostscript_command,lp_options,QKeySequence(keyToggleFocus),pdfCheckerLang,lastScale,StackedViewers);
 3208     pdfviewerWidget->centralToolBarBis->setMinimumHeight(centralToolBarBis->height());
 3209     pdfviewerWidget->centralToolBarBis->setMaximumHeight(centralToolBarBis->height());
 3210     connect(pdfviewerWidget, SIGNAL(openDocAtLine(const QString&, int, bool)), this, SLOT(fileOpenAndGoto(const QString&, int, bool)));
 3211     connect(pdfviewerWidget, SIGNAL(sendFocusToEditor()), this, SLOT(getFocusToEditor()));
 3212     connect(pdfviewerWidget, SIGNAL(sendPaperSize(const QString&)), this, SLOT(setPrintPaperSize(const QString&)));
 3213     StackedViewers->addWidget(pdfviewerWidget);
 3214     StackedViewers->setCurrentWidget(pdfviewerWidget);
 3215     //pdfviewerWidget->raise();
 3216     pdfviewerWidget->show();
 3217     pdfviewerWidget->openFile(outputName(finame,".pdf"),viewpdf_command,ghostscript_command);
 3218     }
 3219     }
 3220   }
 3221 if (currentEditorView()) currentEditorView()->editor->setFocus();
 3222 }
 3223 
 3224 bool Texmaker::isCurrentModifiedOutside()
 3225 {
 3226 if ( !currentEditorView() ) return false;
 3227 QString fn=*filenames.find( currentEditorView() );
 3228 QFileInfo fi(fn);
 3229 fi.refresh();
 3230 QDateTime disktime=fi.lastModified();
 3231 int delta=disktime.secsTo(currentEditorView()->editor->getLastSavedTime());
 3232 if (watchfiles && (delta<-3)) return true;
 3233 else return false;
 3234 }
 3235 
 3236 void Texmaker::checkModifiedOutsideAll()
 3237 {
 3238 if (QApplication::activeWindow() != this) return;
 3239 
 3240 QList<QTreeWidgetItem *> fItems;
 3241 bool islabels_expanded=false;
 3242 bool isblocks_expanded=true;
 3243 fItems=StructureTreeWidget->findItems ("LABELS",Qt::MatchRecursive,0);
 3244 if (fItems.size()>0 ) 
 3245   {
 3246   if (fItems.at(0)) 
 3247       {
 3248       islabels_expanded=fItems.at(0)->isExpanded();
 3249       }
 3250   }
 3251 fItems.clear();
 3252 fItems=StructureTreeWidget->findItems ("BLOCKS",Qt::MatchRecursive,0);
 3253 if (fItems.size()>0 ) 
 3254   {
 3255   if (fItems.at(0)) 
 3256       {
 3257       isblocks_expanded=fItems.at(0)->isExpanded();
 3258       }
 3259   }  
 3260 LatexEditorView *temp = new LatexEditorView(EditorView,EditorFont,svnEnable,showline,edcolors(),hicolors(),inlinespellcheck,spell_ignored_words,spellChecker,tabspaces,tabwidth,QKeySequence(keyToggleFocus),getName(),userTagsList);
 3261 temp=currentEditorView();
 3262 FilesMap::Iterator it;
 3263 QString fn;
 3264 int choice;
 3265 disconnect(EditorView, SIGNAL( currentChanged( int ) ), this, SLOT(UpdateStructure()) ); //*******
 3266 for( it = filenames.begin(); it != filenames.end(); ++it )
 3267     {
 3268     EditorView->setCurrentIndex(EditorView->indexOf(it.key()));
 3269     if ( !getName().startsWith("untitled")) 
 3270         {
 3271         fn=*filenames.find( currentEditorView() );
 3272         if (isCurrentModifiedOutside())
 3273           {
 3274           QFileInfo fi(fn);
 3275           choice= QMessageBox::warning(this, "Texmaker",
 3276                         tr("The document has been changed outside Texmaker."
 3277                         "Do you want to reload it (and discard your changes) or save it (and overwrite the file)?"),
 3278                         tr("Reload the file"), tr("Save"), tr("Cancel"),
 3279                         0,
 3280                         2 );
 3281           if (choice==0)
 3282         {
 3283           if (fi.exists() && fi.isReadable())
 3284             {
 3285             QFile file( fn );
 3286             if (file.open( QIODevice::ReadOnly ) )
 3287             {
 3288             QApplication::setOverrideCursor(QCursor(Qt::WaitCursor));
 3289             QTextStream ts( &file );
 3290             QTextCodec* codec = QTextCodec::codecForName(currentEditorView()->editor->getEncoding().toLatin1());
 3291             ts.setCodec(codec ? codec : QTextCodec::codecForLocale());
 3292             disconnect(currentEditorView()->editor->document(), SIGNAL(modificationChanged(bool)), this, SLOT(NewDocumentStatus(bool)));
 3293             disconnect(currentEditorView()->editor, SIGNAL(spellme()), this, SLOT(editSpell()));
 3294             disconnect(currentEditorView()->editor, SIGNAL(tooltiptab()), this, SLOT(editTipTab()));
 3295             disconnect(currentEditorView()->editor, SIGNAL(requestUpdateStructure()), this, SLOT(UpdateStructure()));
 3296             disconnect(currentEditorView()->editor, SIGNAL(requestpdf(int)),this, SLOT(jumpToPdfline(int)));
 3297             disconnect(currentEditorView()->editor->document(), SIGNAL(undoAvailable(bool)),UndoAct, SLOT(setEnabled(bool)));
 3298             disconnect(currentEditorView()->editor->document(), SIGNAL(redoAvailable(bool)),RedoAct, SLOT(setEnabled(bool)));
 3299             disconnect(currentEditorView()->editor, SIGNAL(copyAvailable(bool)), CutAct, SLOT(setEnabled(bool)));
 3300             disconnect(currentEditorView()->editor, SIGNAL(copyAvailable(bool)), CopyAct, SLOT(setEnabled(bool)));
 3301             disconnect(currentEditorView()->editor, SIGNAL(numLinesChanged(int)), this, SLOT(refreshAllFromCursor(int)));
 3302             disconnect(currentEditorView()->editor, SIGNAL(requestGotoStructure(int)),this, SLOT(jumpToStructure(int)));
 3303             disconnect(currentEditorView()->editor, SIGNAL(poshaschanged(int,int)),this, SLOT(showCursorPos(int,int)));
 3304             currentEditorView()->editor->setPlainText( ts.readAll() );
 3305             file.close();
 3306             currentEditorView()->editor->setLastSavedTime(QDateTime::currentDateTime());
 3307             connect(currentEditorView()->editor->document(), SIGNAL(modificationChanged(bool)), this, SLOT(NewDocumentStatus(bool)));
 3308             connect(currentEditorView()->editor, SIGNAL(spellme()), this, SLOT(editSpell()));
 3309             connect(currentEditorView()->editor, SIGNAL(tooltiptab()), this, SLOT(editTipTab()));
 3310             connect(currentEditorView()->editor, SIGNAL(requestUpdateStructure()), this, SLOT(UpdateStructure()));
 3311             connect(currentEditorView()->editor, SIGNAL(requestpdf(int)),this, SLOT(jumpToPdfline(int)));
 3312             connect(currentEditorView()->editor->document(), SIGNAL(undoAvailable(bool)),UndoAct, SLOT(setEnabled(bool)));
 3313             connect(currentEditorView()->editor->document(), SIGNAL(redoAvailable(bool)),RedoAct, SLOT(setEnabled(bool)));
 3314             connect(currentEditorView()->editor, SIGNAL(copyAvailable(bool)), CutAct, SLOT(setEnabled(bool)));
 3315             connect(currentEditorView()->editor, SIGNAL(copyAvailable(bool)), CopyAct, SLOT(setEnabled(bool)));
 3316             currentEditorView()->editor->setLastNumLines(currentEditorView()->editor->numoflines());
 3317             connect(currentEditorView()->editor, SIGNAL(numLinesChanged(int)), this, SLOT(refreshAllFromCursor(int)));
 3318             connect(currentEditorView()->editor, SIGNAL(requestGotoStructure(int)),this, SLOT(jumpToStructure(int)));
 3319             connect(currentEditorView()->editor, SIGNAL(poshaschanged(int,int)),this, SLOT(showCursorPos(int,int)));
 3320             UpdateStructure();
 3321             UpdateBibliography();
 3322             QApplication::restoreOverrideCursor();
 3323             }
 3324             }
 3325         }
 3326           else if (choice==1)
 3327         {
 3328         QFile file(fn);
 3329         if (file.open( QIODevice::WriteOnly ) )
 3330             {
 3331             QTextStream ts( &file );
 3332             QTextCodec* codec = QTextCodec::codecForName(currentEditorView()->editor->getEncoding().toLatin1());
 3333             ts.setCodec(codec ? codec : QTextCodec::codecForLocale());
 3334             ts << currentEditorView()->editor->toPlainText();
 3335             file.close();
 3336             currentEditorView()->editor->setLastSavedTime(QDateTime::currentDateTime());
 3337             currentEditorView()->editor->document()->setModified(false);
 3338             }
 3339         }
 3340         else currentEditorView()->editor->setLastSavedTime(QDateTime::currentDateTime());
 3341           }
 3342         }
 3343     }
 3344 
 3345 EditorView->setCurrentIndex(EditorView->indexOf(temp));
 3346 connect(EditorView, SIGNAL( currentChanged( int ) ), this, SLOT(UpdateStructure()) ); //********
 3347 QString title;
 3348 if   ( !currentEditorView() )   {title="Texmaker";}
 3349 else
 3350     {
 3351     title="Document : "+getName();
 3352     //input_encoding=currentEditorView()->editor->getEncoding();
 3353     }
 3354 setWindowTitle(title);
 3355 
 3356 UpdateStructure();
 3357 fItems.clear();
 3358 fItems=StructureTreeWidget->findItems ("LABELS",Qt::MatchRecursive,0);
 3359 if (fItems.size()>0 ) 
 3360   {
 3361   if (fItems.at(0)) 
 3362       {
 3363       StructureTreeWidget->setItemExpanded(fItems.at(0),islabels_expanded);
 3364       }
 3365   }
 3366 fItems.clear();
 3367 fItems=StructureTreeWidget->findItems ("BLOCKS",Qt::MatchRecursive,0);
 3368 if (fItems.size()>0 ) 
 3369   {
 3370   if (fItems.at(0)) 
 3371       {
 3372       StructureTreeWidget->setItemExpanded (fItems.at(0),isblocks_expanded);
 3373       }
 3374   }  
 3375 
 3376 QString finame=getName();
 3377 int check=comboFiles->findData(finame,Qt::UserRole,Qt::MatchExactly | Qt::MatchCaseSensitive);
 3378 comboFiles->setCurrentIndex(check);
 3379 if ((check>-1) && (check<OpenedFilesListWidget->count())) OpenedFilesListWidget->setCurrentRow(check);
 3380 
 3381 
 3382 if (!finame.startsWith("untitled") && finame!="") 
 3383   {
 3384   lastDocument=finame;
 3385 
 3386   }
 3387 if   (currentEditorView())
 3388   {
 3389    SaveAct->setEnabled(currentEditorView()->editor->document()->isModified());
 3390    UndoAct->setEnabled(currentEditorView()->editor->document()->isUndoAvailable());
 3391    RedoAct->setEnabled(currentEditorView()->editor->document()->isRedoAvailable());
 3392    CopyAct->setEnabled(currentEditorView()->editor->textCursor().hasSelection());
 3393    CutAct->setEnabled(currentEditorView()->editor->textCursor().hasSelection());
 3394    stat3->setText(QString(" %1 ").arg(currentEditorView()->editor->getEncoding()));
 3395   }
 3396 else
 3397   {
 3398    SaveAct->setEnabled(false);
 3399    UndoAct->setEnabled(false);
 3400    RedoAct->setEnabled(false);
 3401    CopyAct->setEnabled(false);
 3402    CutAct->setEnabled(false);    
 3403   }
 3404 if (currentEditorView()) currentEditorView()->editor->setFocus();
 3405 }
 3406 
 3407 void Texmaker::fileSave()
 3408 {
 3409 if ( !currentEditorView() ) return;
 3410 QString fn;
 3411 if ( getName().startsWith("untitled") ) {fileSaveAs();}
 3412 else
 3413     {
 3414     fn=*filenames.find( currentEditorView() );
 3415     if (isCurrentModifiedOutside())
 3416     {
 3417     QFileInfo fi(fn);
 3418     switch(  QMessageBox::warning(this, "Texmaker",
 3419                     tr("The document has been changed outside Texmaker."
 3420                     "Do you want to reload it (and discard your changes) or save it (and overwrite the file)?"),
 3421                     tr("Reload the file"), tr("Save"), tr("Cancel"),
 3422                     0,
 3423                     2 ) )
 3424         {
 3425         case 0:
 3426           if (fi.exists() && fi.isReadable())
 3427             {
 3428             filenames.