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 CONFIGURATION_H 21 #define CONFIGURATION_H 22 23 #include <QFont> 24 #include <QSettings> 25 26 #include "persistable.h" 27 28 // Type of regexp to use for searches 29 enum SearchRegexpType { 30 ExtendedRegexp, 31 Wildcard, 32 FixedString, 33 }; 34 35 // Configuration class containing everything in the "Settings" dialog 36 class Configuration : public Persistable { 37 public: 38 Configuration(); 39 40 // Accesses the main font used for display 41 QFont mainFont() const; 42 void setMainFont( QFont newFont ); 43 44 // Accesses the regexp types 45 SearchRegexpType mainRegexpType() const 46 { return mainRegexpType_; } 47 SearchRegexpType quickfindRegexpType() const 48 { return quickfindRegexpType_; } 49 bool isQuickfindIncremental() const 50 { return quickfindIncremental_; } 51 void setMainRegexpType( SearchRegexpType type ) 52 { mainRegexpType_ = type; } 53 void setQuickfindRegexpType( SearchRegexpType type ) 54 { quickfindRegexpType_ = type; } 55 void setQuickfindIncremental( bool is_incremental ) 56 { quickfindIncremental_ = is_incremental; } 57 58 // View settings 59 bool isOverviewVisible() const 60 { return overviewVisible_; } 61 void setOverviewVisible( bool isVisible ) 62 { overviewVisible_ = isVisible; } 63 bool mainLineNumbersVisible() const 64 { return lineNumbersVisibleInMain_; } 65 bool filteredLineNumbersVisible() const 66 { return lineNumbersVisibleInFiltered_; } 67 void setMainLineNumbersVisible( bool lineNumbersVisible ) 68 { lineNumbersVisibleInMain_ = lineNumbersVisible; } 69 void setFilteredLineNumbersVisible( bool lineNumbersVisible ) 70 { lineNumbersVisibleInFiltered_ = lineNumbersVisible; } 71 72 // Default settings for new views 73 bool isSearchAutoRefreshDefault() const 74 { return searchAutoRefresh_; } 75 void setSearchAutoRefreshDefault( bool auto_refresh ) 76 { searchAutoRefresh_ = auto_refresh; } 77 bool isSearchIgnoreCaseDefault() const 78 { return searchIgnoreCase_; } 79 void setSearchIgnoreCaseDefault( bool ignore_case ) 80 { searchIgnoreCase_ = ignore_case; } 81 82 // Reads/writes the current config in the QSettings object passed 83 virtual void saveToStorage( QSettings& settings ) const; 84 virtual void retrieveFromStorage( QSettings& settings ); 85 86 private: 87 // Configuration settings 88 QFont mainFont_; 89 SearchRegexpType mainRegexpType_; 90 SearchRegexpType quickfindRegexpType_; 91 bool quickfindIncremental_; 92 93 // View settings 94 bool overviewVisible_; 95 bool lineNumbersVisibleInMain_; 96 bool lineNumbersVisibleInFiltered_; 97 98 // Default settings for new views 99 bool searchAutoRefresh_; 100 bool searchIgnoreCase_; 101 }; 102 103 #endif 104