1bb02e0acSNicolas Bonnefon /* 2bb02e0acSNicolas Bonnefon * Copyright (C) 2009, 2010, 2011, 2013 Nicolas Bonnefon and other contributors 3bb02e0acSNicolas Bonnefon * 4bb02e0acSNicolas Bonnefon * This file is part of glogg. 5bb02e0acSNicolas Bonnefon * 6bb02e0acSNicolas Bonnefon * glogg is free software: you can redistribute it and/or modify 7bb02e0acSNicolas Bonnefon * it under the terms of the GNU General Public License as published by 8bb02e0acSNicolas Bonnefon * the Free Software Foundation, either version 3 of the License, or 9bb02e0acSNicolas Bonnefon * (at your option) any later version. 10bb02e0acSNicolas Bonnefon * 11bb02e0acSNicolas Bonnefon * glogg is distributed in the hope that it will be useful, 12bb02e0acSNicolas Bonnefon * but WITHOUT ANY WARRANTY; without even the implied warranty of 13bb02e0acSNicolas Bonnefon * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14bb02e0acSNicolas Bonnefon * GNU General Public License for more details. 15bb02e0acSNicolas Bonnefon * 16bb02e0acSNicolas Bonnefon * You should have received a copy of the GNU General Public License 17bb02e0acSNicolas Bonnefon * along with glogg. If not, see <http://www.gnu.org/licenses/>. 18bb02e0acSNicolas Bonnefon */ 19bb02e0acSNicolas Bonnefon 20bb02e0acSNicolas Bonnefon #ifndef MAINWINDOW_H 21bb02e0acSNicolas Bonnefon #define MAINWINDOW_H 22bb02e0acSNicolas Bonnefon 23d96f3f21SNicolas Bonnefon #include <memory> 24bb02e0acSNicolas Bonnefon #include <QMainWindow> 25*27ddfd3aSNicolas Bonnefon #include <QTabWidget> 26d96f3f21SNicolas Bonnefon 27d96f3f21SNicolas Bonnefon #include "session.h" 28bb02e0acSNicolas Bonnefon #include "crawlerwidget.h" 29bb02e0acSNicolas Bonnefon #include "infoline.h" 30313a820fSNicolas Bonnefon #include "signalmux.h" 31bb02e0acSNicolas Bonnefon 32bb02e0acSNicolas Bonnefon class QAction; 33d96f3f21SNicolas Bonnefon class Session; 34bb02e0acSNicolas Bonnefon class RecentFiles; 35bb02e0acSNicolas Bonnefon class MenuActionToolTipBehavior; 36bb02e0acSNicolas Bonnefon 37bb02e0acSNicolas Bonnefon // Main window of the application, creates menus, toolbar and 38bb02e0acSNicolas Bonnefon // the CrawlerWidget 39bb02e0acSNicolas Bonnefon class MainWindow : public QMainWindow 40bb02e0acSNicolas Bonnefon { 41bb02e0acSNicolas Bonnefon Q_OBJECT 42bb02e0acSNicolas Bonnefon 43bb02e0acSNicolas Bonnefon public: 44d96f3f21SNicolas Bonnefon // Constructor 45d96f3f21SNicolas Bonnefon // The ownership of the session is transferred to us 46d96f3f21SNicolas Bonnefon MainWindow( std::unique_ptr<Session> session ); 47bb02e0acSNicolas Bonnefon 48bb02e0acSNicolas Bonnefon // Loads the initial file (parameter passed or from config file) 49bb02e0acSNicolas Bonnefon void loadInitialFile( QString fileName ); 50bb02e0acSNicolas Bonnefon 51bb02e0acSNicolas Bonnefon protected: 52bb02e0acSNicolas Bonnefon void closeEvent( QCloseEvent* event ); 53bb02e0acSNicolas Bonnefon // Drag and drop support 54bb02e0acSNicolas Bonnefon void dragEnterEvent( QDragEnterEvent* event ); 55bb02e0acSNicolas Bonnefon void dropEvent( QDropEvent* event ); 56bb02e0acSNicolas Bonnefon 57bb02e0acSNicolas Bonnefon private slots: 58bb02e0acSNicolas Bonnefon void open(); 59bb02e0acSNicolas Bonnefon void openRecentFile(); 60bb02e0acSNicolas Bonnefon void selectAll(); 61bb02e0acSNicolas Bonnefon void copy(); 62bb02e0acSNicolas Bonnefon void find(); 63bb02e0acSNicolas Bonnefon void filters(); 64bb02e0acSNicolas Bonnefon void options(); 65bb02e0acSNicolas Bonnefon void about(); 66bb02e0acSNicolas Bonnefon void aboutQt(); 67bb02e0acSNicolas Bonnefon 68bb02e0acSNicolas Bonnefon // Change the view settings 69bb02e0acSNicolas Bonnefon void toggleOverviewVisibility( bool isVisible ); 70bb02e0acSNicolas Bonnefon void toggleMainLineNumbersVisibility( bool isVisible ); 71bb02e0acSNicolas Bonnefon void toggleFilteredLineNumbersVisibility( bool isVisible ); 72bb02e0acSNicolas Bonnefon 73bb02e0acSNicolas Bonnefon // Disable the follow mode checkbox and send the followSet signal down 74bb02e0acSNicolas Bonnefon void disableFollow(); 75bb02e0acSNicolas Bonnefon 76bb02e0acSNicolas Bonnefon // Update the line number displayed in the status bar. 77bb02e0acSNicolas Bonnefon // Must be passed as the internal (starts at 0) line number. 78bb02e0acSNicolas Bonnefon void lineNumberHandler( int line ); 79bb02e0acSNicolas Bonnefon 80bb02e0acSNicolas Bonnefon // Instructs the widget to update the loading progress gauge 81bb02e0acSNicolas Bonnefon void updateLoadingProgress( int progress ); 82bb02e0acSNicolas Bonnefon // Instructs the widget to display the 'normal' status bar, 83bb02e0acSNicolas Bonnefon // without the progress gauge and with file info 84bb02e0acSNicolas Bonnefon void displayNormalStatus( bool success ); 85bb02e0acSNicolas Bonnefon 86bb02e0acSNicolas Bonnefon 87bb02e0acSNicolas Bonnefon signals: 88bb02e0acSNicolas Bonnefon // Is emitted when new settings must be used 89bb02e0acSNicolas Bonnefon void optionsChanged(); 90bb02e0acSNicolas Bonnefon // Is emitted when the 'follow' option is enabled/disabled 91bb02e0acSNicolas Bonnefon void followSet( bool checked ); 92bb02e0acSNicolas Bonnefon 93bb02e0acSNicolas Bonnefon private: 94bb02e0acSNicolas Bonnefon void createActions(); 95bb02e0acSNicolas Bonnefon void createMenus(); 96bb02e0acSNicolas Bonnefon void createContextMenu(); 97bb02e0acSNicolas Bonnefon void createToolBars(); 98bb02e0acSNicolas Bonnefon void createStatusBar(); 99bb02e0acSNicolas Bonnefon void createRecentFileToolTipTimer(); 100bb02e0acSNicolas Bonnefon void readSettings(); 101bb02e0acSNicolas Bonnefon void writeSettings(); 102bb02e0acSNicolas Bonnefon bool loadFile( const QString& fileName ); 103bb02e0acSNicolas Bonnefon void setCurrentFile( const QString& fileName ); 104bb02e0acSNicolas Bonnefon void updateRecentFileActions(); 105bb02e0acSNicolas Bonnefon QString strippedName( const QString& fullFileName ) const; 106*27ddfd3aSNicolas Bonnefon CrawlerWidget* currentCrawlerWidget() const; 107bb02e0acSNicolas Bonnefon 108d96f3f21SNicolas Bonnefon std::unique_ptr<Session> session_; 109bb02e0acSNicolas Bonnefon SavedSearches *savedSearches; 110bb02e0acSNicolas Bonnefon RecentFiles& recentFiles; 111bb02e0acSNicolas Bonnefon QString loadingFileName; 112bb02e0acSNicolas Bonnefon QString currentFile; 113bb02e0acSNicolas Bonnefon QString previousFile; 114bb02e0acSNicolas Bonnefon 115bb02e0acSNicolas Bonnefon enum { MaxRecentFiles = 5 }; 116bb02e0acSNicolas Bonnefon QAction *recentFileActions[MaxRecentFiles]; 117bb02e0acSNicolas Bonnefon MenuActionToolTipBehavior *recentFileActionBehaviors[MaxRecentFiles]; 118bb02e0acSNicolas Bonnefon QAction *separatorAction; 119bb02e0acSNicolas Bonnefon 120bb02e0acSNicolas Bonnefon QMenu *fileMenu; 121bb02e0acSNicolas Bonnefon QMenu *editMenu; 122bb02e0acSNicolas Bonnefon QMenu *viewMenu; 123bb02e0acSNicolas Bonnefon QMenu *toolsMenu; 124bb02e0acSNicolas Bonnefon QMenu *helpMenu; 125bb02e0acSNicolas Bonnefon 126bb02e0acSNicolas Bonnefon InfoLine *infoLine; 127bb02e0acSNicolas Bonnefon QLabel* lineNbField; 128bb02e0acSNicolas Bonnefon QToolBar *toolBar; 129bb02e0acSNicolas Bonnefon 130bb02e0acSNicolas Bonnefon QAction *openAction; 131bb02e0acSNicolas Bonnefon QAction *exitAction; 132bb02e0acSNicolas Bonnefon QAction *copyAction; 133bb02e0acSNicolas Bonnefon QAction *selectAllAction; 134bb02e0acSNicolas Bonnefon QAction *findAction; 135bb02e0acSNicolas Bonnefon QAction *overviewVisibleAction; 136bb02e0acSNicolas Bonnefon QAction *lineNumbersVisibleInMainAction; 137bb02e0acSNicolas Bonnefon QAction *lineNumbersVisibleInFilteredAction; 138bb02e0acSNicolas Bonnefon QAction *followAction; 139bb02e0acSNicolas Bonnefon QAction *reloadAction; 140bb02e0acSNicolas Bonnefon QAction *stopAction; 141bb02e0acSNicolas Bonnefon QAction *filtersAction; 142bb02e0acSNicolas Bonnefon QAction *optionsAction; 143bb02e0acSNicolas Bonnefon QAction *aboutAction; 144bb02e0acSNicolas Bonnefon QAction *aboutQtAction; 145bb02e0acSNicolas Bonnefon 146bb02e0acSNicolas Bonnefon QIcon mainIcon_; 147313a820fSNicolas Bonnefon 148313a820fSNicolas Bonnefon // Multiplex signals to any of the CrawlerWidgets 149313a820fSNicolas Bonnefon SignalMux signalMux_; 150*27ddfd3aSNicolas Bonnefon 151*27ddfd3aSNicolas Bonnefon // The main widget 152*27ddfd3aSNicolas Bonnefon QTabWidget mainTabWidget_; 153bb02e0acSNicolas Bonnefon }; 154bb02e0acSNicolas Bonnefon 155bb02e0acSNicolas Bonnefon #endif 156