File indexing completed on 2024-04-14 15:17:33
0001 /*************************************************************************************** 0002 begin : sam jui 13 09:50:06 CEST 2002 0003 copyright : (C) 2003 by Jeroen Wijnhout (wijnhout@science.uva.nl) 0004 2007-2019 by Michel Ludwig (michel.ludwig@kdemail.net) 0005 (C) 2009 Thomas Braun (thomas.braun@virtuell-zuhause.de) 0006 0007 ***************************************************************************************/ 0008 0009 /*************************************************************************** 0010 * * 0011 * This program is free software; you can redistribute it and/or modify * 0012 * it under the terms of the GNU General Public License as published by * 0013 * the Free Software Foundation; either version 2 of the License, or * 0014 * (at your option) any later version. * 0015 * * 0016 ***************************************************************************/ 0017 0018 #ifndef KILE_H 0019 #define KILE_H 0020 0021 #include <QList> 0022 #include <QSplitter> 0023 #include <QStackedWidget> 0024 #include <QString> 0025 #include <QStringList> 0026 #include <QToolBox> 0027 #include <QWidget> 0028 0029 #include <KTextEditor/View> 0030 #include <KTextEditor/Document> 0031 #include <ktogglefullscreenaction.h> 0032 #include <KXmlGuiWindow> 0033 0034 #include "widgets/filebrowserwidget.h" 0035 #include "kileinfo.h" 0036 #include "kileactions.h" 0037 #include "kileversion.h" 0038 #include "widgets/symbolview.h" 0039 #include "widgets/commandview.h" 0040 0041 #include "outputinfo.h" 0042 0043 #include "codecompletion.h" // code completion (dani) 0044 #include "editorextension.h" // advanced editor (dani) 0045 #include "kilehelp.h" // kile help (dani) 0046 #include "quickpreview.h" 0047 #include "widgets/abbreviationview.h" 0048 0049 class QFileInfo; 0050 class QTimer; 0051 0052 class KToolBar; 0053 class QAction; 0054 class KActionMenu; 0055 class KRecentFilesAction; 0056 class KToggleFullScreenAction; 0057 class KToggleToolBarAction; 0058 class KMultiTabBar; 0059 0060 namespace KParts { 0061 class MainWindow; 0062 } 0063 0064 class KileLyxServer; 0065 class KileProject; 0066 class KileProjectItem; 0067 class TemplateItem; 0068 class KileAutoSaveJob; 0069 0070 namespace KileAction { 0071 class TagData; 0072 } 0073 namespace KileDocument { 0074 class Info; 0075 class TextInfo; 0076 class Extensions; 0077 } 0078 namespace KileTool { 0079 class Manager; 0080 class Factory; 0081 } 0082 namespace KileWidget { 0083 class LogWidget; 0084 class Output; 0085 class Konsole; 0086 class StructureWidget; 0087 class SideBar; 0088 class BottomBar; 0089 class StatusBar; 0090 } 0091 0092 //TODO remove once we stop supporting pre 1.7 user tools 0093 struct userItem 0094 { 0095 QString name, tag; 0096 }; 0097 0098 /** 0099 * The Kile main class. It acts as information manager and DBUS interface. 0100 **/ 0101 class Kile : public KParts::MainWindow, public KileInfo 0102 { 0103 Q_OBJECT 0104 0105 public: 0106 explicit Kile(bool allowRestore = true, QWidget *parent = Q_NULLPTR); 0107 ~Kile(); 0108 0109 int lineNumber() override; 0110 KileWidget::StatusBar * statusBar(); 0111 0112 public Q_SLOTS: 0113 void setCursor(const QUrl &, int, int); 0114 0115 void runArchiveTool(); 0116 void runArchiveTool(const QUrl&); 0117 0118 void updateModeStatus(); 0119 void newCaption(); 0120 0121 void rebuildBibliographyMenu(); 0122 0123 void openDocument(const QUrl &url); 0124 void openProject(const QUrl &url); 0125 0126 // D-Bus Interface 0127 void openDocument(const QString & url); 0128 void closeDocument(); 0129 void setActive(); 0130 /** 0131 * @param line : Jump to give line in current editor (can be called via DBUS interface). 0132 **/ 0133 void setLine(const QString &line) override; 0134 void openProject(const QString& proj); 0135 void runTool(const QString& tool); 0136 void runToolWithConfig(const QString &tool, const QString &config); 0137 void insertText(const QString &text); 0138 void insertTag(const KileAction::TagData& td); 0139 0140 Q_SIGNALS: 0141 void masterDocumentChanged(); 0142 0143 protected: 0144 virtual bool queryClose() override; 0145 0146 private: 0147 QMap<QString,bool> m_dictMenuAction, 0148 m_dictMenuFile, 0149 m_dictMenuProject; 0150 0151 KToolBar *m_toolsToolBar; 0152 KActionMenu *m_userHelpActionMenu; 0153 KSelectAction *m_bibTagSettings; 0154 ToolbarSelectAction *m_compilerActions, 0155 *m_viewActions, 0156 *m_convertActions, 0157 *m_quickActions; 0158 0159 QList<KileAction::TagData> m_listUserTags; 0160 QList<userItem> m_listUserTools; 0161 QList<QAction*> m_listQuickActions, 0162 m_listCompilerActions, 0163 m_listConverterActions, 0164 m_listViewerActions, 0165 m_listOtherActions; 0166 0167 KActionMenu *m_bibTagActionMenu; 0168 KToggleAction *ModeAction, 0169 *WatchFileAction; 0170 KToggleAction *m_actionMessageView; 0171 KToggleAction *m_actionShowMenuBar; 0172 KRecentFilesAction *m_actRecentFiles; 0173 KToggleFullScreenAction *m_pFullScreen; 0174 0175 /* GUI */ 0176 //widgets 0177 KileWidget::SideBar *m_sideBar; 0178 KileWidget::AbbreviationView *m_kileAbbrevView; 0179 QStackedWidget *m_topWidgetStack; 0180 QSplitter *m_horizontalSplitter, 0181 *m_verticalSplitter; 0182 QToolBox *m_toolBox; 0183 KileWidget::CommandViewToolBox *m_commandViewToolBox; 0184 KileWidget::SymbolView *m_symbolViewMFUS, 0185 *m_symbolViewRelation, 0186 *m_symbolViewArrows, 0187 *m_symbolViewMiscMath, 0188 *m_symbolViewMiscText, 0189 *m_symbolViewOperators, 0190 *m_symbolViewUser, 0191 *m_symbolViewDelimiters, 0192 *m_symbolViewGreek, 0193 *m_symbolViewSpecial, 0194 *m_symbolViewCyrillic; 0195 KileWidget::CommandView *m_commandView; 0196 KToolBar *m_latexOutputErrorToolBar; 0197 QMenu *m_buildMenuTopLevel, 0198 *m_buildMenuCompile, 0199 *m_buildMenuConvert, 0200 *m_buildMenuViewer, 0201 *m_buildMenuOther, 0202 *m_buildMenuQuickPreview; 0203 0204 /* config */ 0205 KSharedConfigPtr m_config; 0206 QStringList m_recentFilesList, 0207 m_listDocsOpenOnStart, 0208 m_listEncodingsOfDocsOpenOnStart, 0209 m_listProjectsOpenOnStart; 0210 0211 KRecentFilesAction *m_actRecentProjects; 0212 0213 KileLyxServer *m_lyxserver; 0214 0215 /* actions */ 0216 void initSelectActions(); 0217 void setupSideBar(); 0218 void setupProjectView(); 0219 void setupStructureView(); 0220 void setupScriptsManagementView(); 0221 void setupCommandViewToolbox(); 0222 void setupSymbolViews(); 0223 void enableSymbolViewMFUS(); 0224 void disableSymbolViewMFUS(); 0225 void setupAbbreviationView(); 0226 void setupBottomBar(); 0227 void setupGraphicTools(); 0228 void setupPreviewTools(); 0229 void setupActions(); 0230 QAction* createToolAction(const QString& toolName); 0231 void createToolActions(); 0232 void setupTools(); 0233 void updateUserDefinedMenus(); 0234 void cleanUpActionList(QList<QAction*> &list, const QStringList &tools); 0235 void restoreLastSelectedAction(); 0236 void saveLastSelectedAction(); 0237 0238 void transformOldUserTags(); 0239 0240 void initMenu(); 0241 void setMenuItems(QStringList &list, QMap<QString,bool> &dict); 0242 void updateMenu(); 0243 bool updateMenuActivationStatus(QMenu *menu); 0244 bool updateMenuActivationStatus(QMenu *menu, const QSet<QMenu*>& visited); 0245 void updateLatexenuActivationStatus(QMenu *menu, bool state); 0246 void updateUserMenuStatus(bool state); 0247 0248 template<class ContextType, class Func> 0249 inline QAction* createAction(const QString &text, const char* actionName, const ContextType* context, Func function) 0250 { 0251 return createAction<ContextType, Func>(text, actionName, QString(), QKeySequence(), context, function); 0252 } 0253 0254 template<class ContextType, class Func> 0255 inline QAction* createAction(const QString &text, const char* actionName, const QString& iconName, const ContextType* context, Func function) 0256 { 0257 return createAction<ContextType, Func>(text, QLatin1String(actionName), iconName, QKeySequence(), context, function); 0258 } 0259 0260 template<class ContextType, class Func> 0261 QAction* createAction(const QString &text, const QString& actionName, const QString& iconName, const ContextType* context, Func function) 0262 { 0263 return createAction<ContextType, Func>(text, actionName, iconName, QKeySequence(), context, function); 0264 } 0265 0266 template<class ContextType, class Func> 0267 inline QAction* createAction(const QString &text, const char* actionName, const QKeySequence& shortcut, const ContextType* context, Func function) 0268 { 0269 return createAction<ContextType, Func>(text, actionName, QString(), shortcut, context, function); 0270 } 0271 0272 template<class ContextType, class Func> 0273 inline QAction* createAction(const QString &text, const char* actionName, const QString& iconName, const QKeySequence& shortcut, 0274 const ContextType* context, Func function) 0275 { 0276 return createAction<ContextType, Func>(text, QLatin1String(actionName), iconName, shortcut, context, function); 0277 } 0278 0279 template<class ContextType, class Func> 0280 QAction* createAction(const QString &text, const QString& actionName, const QString& iconName, const QKeySequence& shortcut, 0281 const ContextType* context, Func function); 0282 0283 template<class ContextType, class Func> 0284 inline QAction* createAction(KStandardAction::StandardAction actionType, const ContextType* context, Func function) 0285 { 0286 return createAction<ContextType, Func>(actionType, QString(), context, function); 0287 } 0288 0289 template<class ContextType, class Func> 0290 QAction* createAction(KStandardAction::StandardAction actionType, const QString &name, const ContextType* context, Func function); 0291 0292 template<class ContextType, class Func> 0293 QAction* createAction(const QString &text, const QString &actionName, const QString& iconName, const QList<QKeySequence>& shortcut, const ContextType* context, Func function); 0294 0295 void setMasterDocumentFileName(const QString& fileName); 0296 void clearMasterDocument(); 0297 0298 private Q_SLOTS: 0299 void toggleMasterDocumentMode(); 0300 void toggleWatchFile(); 0301 void refreshStructure(); 0302 0303 bool resetPart(); 0304 void enableGUI(bool); 0305 void slotToggleFullScreen(); 0306 0307 void toggleShowMenuBar(bool showMessage = true); 0308 0309 void restoreFilesAndProjects(bool allowRestore); 0310 void readGUISettings(); 0311 void transformOldUserSettings(); 0312 void readRecentFileSettings(); 0313 void saveSettings(); 0314 0315 void readConfig(); 0316 0317 void generalOptions(); 0318 void configureKeys(); 0319 void configureToolbars() override; 0320 void slotPerformCheck(); 0321 0322 void aboutEditorComponent(); 0323 0324 /** 0325 * Activates (sets up the GUI for the editor part) the view. 0326 * @param updateStruct If true, force an update of the structure view. 0327 **/ 0328 void activateView(QWidget* view, bool updateStruct = true); 0329 0330 void focusLog() override; 0331 void focusOutput() override; 0332 void focusKonsole() override; 0333 void focusEditor() override; 0334 void focusPreview() override; 0335 0336 void sideOrBottomBarChanged(bool visible); 0337 0338 void showDocInfo(KTextEditor::View *view = Q_NULLPTR); 0339 void convertToASCII(KTextEditor::Document *doc = Q_NULLPTR); 0340 void convertToEnc(KTextEditor::Document *doc = Q_NULLPTR); 0341 0342 void cleanAll(KileDocument::TextInfo *docinfo = Q_NULLPTR); 0343 void cleanBib(); 0344 0345 void findInFiles(); 0346 void findInProjects(); 0347 void grepItemSelected(const QString &abs_filename, int line); 0348 0349 /** 0350 * @param td Inserts the TagData td into the current editor 0351 * @param pkgs list of packages needed for this command 0352 * 0353 * warns if latex packages in pkgs are not included in the document 0354 **/ 0355 void insertTag(const KileAction::TagData& td, const QStringList& pkgs); 0356 0357 /** 0358 * An overloaded member function, behaves essentially as above. 0359 **/ 0360 0361 void insertTag(const KileAction::TagData& td, const QList<Package>& pkgs); 0362 void insertTag(const QString& tagB, const QString& tagE, int dx, int dy); 0363 void insertAmsTag(const KileAction::TagData& td); 0364 void insertText(const QString &text, const QStringList &pkgs); 0365 void insertText(const QString &text, const QList<Package> &pkgs); 0366 0367 void quickTabular(); 0368 void quickArray(); 0369 void quickTabbing(); 0370 void quickDocument(); 0371 void quickFloat(); 0372 void quickMathenv(); 0373 void quickPostscript(); 0374 void quickPdf(); 0375 void quickTabulardialog(bool tabularenv); 0376 0377 void quickUserMenuDialog(); 0378 void slotUpdateUserMenuStatus(); 0379 0380 void includeGraphics(); 0381 0382 // QuickPreview 0383 void slotQuickPreview(int type); 0384 0385 void quickPreviewEnvironment() { 0386 slotQuickPreview(KileTool::qpEnvironment); 0387 } 0388 void quickPreviewSelection() { 0389 slotQuickPreview(KileTool::qpSelection); 0390 } 0391 void quickPreviewSubdocument() { 0392 slotQuickPreview(KileTool::qpSubdocument); 0393 } 0394 void quickPreviewMathgroup() { 0395 slotQuickPreview(KileTool::qpMathgroup); 0396 } 0397 0398 void addRecentFile(const QUrl &url); 0399 void removeRecentFile(const QUrl &url); 0400 void addRecentProject(const QUrl &url); 0401 void removeRecentProject(const QUrl &url); 0402 0403 void updateStatusBarCursorPosition(KTextEditor::View *view, const KTextEditor::Cursor &newPosition); 0404 void updateStatusBarViewMode(KTextEditor::View *view); 0405 void updateStatusBarInformationMessage(KTextEditor::View *view, const QString &message); 0406 void updateStatusBarSelection(KTextEditor::View *view); 0407 0408 void handleDocumentParsingStarted(); 0409 void handleDocumentParsingComplete(); 0410 }; 0411 0412 #endif