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