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