xref: /glogg/src/configuration.h (revision 7cbb2ca4497ec8f4a20fe2586dec49657d3308cb)
1 /*
2  * Copyright (C) 2009, 2010, 2011, 2013, 2015 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,           // Disused!
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
mainRegexpType()45     SearchRegexpType mainRegexpType() const
46     { return mainRegexpType_; }
quickfindRegexpType()47     SearchRegexpType quickfindRegexpType() const
48     { return quickfindRegexpType_; }
isQuickfindIncremental()49     bool isQuickfindIncremental() const
50     { return quickfindIncremental_; }
setMainRegexpType(SearchRegexpType type)51     void setMainRegexpType( SearchRegexpType type )
52     { mainRegexpType_ = type; }
setQuickfindRegexpType(SearchRegexpType type)53     void setQuickfindRegexpType( SearchRegexpType type )
54     { quickfindRegexpType_ = type; }
setQuickfindIncremental(bool is_incremental)55     void setQuickfindIncremental( bool is_incremental )
56     { quickfindIncremental_ = is_incremental; }
57 
58     // "Advanced" settings
pollingEnabled()59     bool pollingEnabled() const
60     { return pollingEnabled_; }
setPollingEnabled(bool enabled)61     void setPollingEnabled( bool enabled )
62     { pollingEnabled_ = enabled; }
pollIntervalMs()63     uint32_t pollIntervalMs() const
64     { return pollIntervalMs_; }
setPollIntervalMs(uint32_t interval)65     void setPollIntervalMs( uint32_t interval )
66     { pollIntervalMs_ = interval; }
loadLastSession()67     bool loadLastSession() const
68     { return loadLastSession_; }
setLoadLastSession(bool enabled)69     void setLoadLastSession( bool enabled )
70     { loadLastSession_ = enabled; }
71 
72     // View settings
isOverviewVisible()73     bool isOverviewVisible() const
74     { return overviewVisible_; }
setOverviewVisible(bool isVisible)75     void setOverviewVisible( bool isVisible )
76     { overviewVisible_ = isVisible; }
mainLineNumbersVisible()77     bool mainLineNumbersVisible() const
78     { return lineNumbersVisibleInMain_; }
filteredLineNumbersVisible()79     bool filteredLineNumbersVisible() const
80     { return lineNumbersVisibleInFiltered_; }
setMainLineNumbersVisible(bool lineNumbersVisible)81     void setMainLineNumbersVisible( bool lineNumbersVisible )
82     { lineNumbersVisibleInMain_ = lineNumbersVisible; }
setFilteredLineNumbersVisible(bool lineNumbersVisible)83     void setFilteredLineNumbersVisible( bool lineNumbersVisible )
84     { lineNumbersVisibleInFiltered_ = lineNumbersVisible; }
85 
86     // Default settings for new views
isSearchAutoRefreshDefault()87     bool isSearchAutoRefreshDefault() const
88     { return searchAutoRefresh_; }
setSearchAutoRefreshDefault(bool auto_refresh)89     void setSearchAutoRefreshDefault( bool auto_refresh )
90     { searchAutoRefresh_ = auto_refresh; }
isSearchIgnoreCaseDefault()91     bool isSearchIgnoreCaseDefault() const
92     { return searchIgnoreCase_; }
setSearchIgnoreCaseDefault(bool ignore_case)93     void setSearchIgnoreCaseDefault( bool ignore_case )
94     { searchIgnoreCase_ = ignore_case; }
95 
96     // Reads/writes the current config in the QSettings object passed
97     virtual void saveToStorage( QSettings& settings ) const;
98     virtual void retrieveFromStorage( QSettings& settings );
99 
100   private:
101     // Configuration settings
102     QFont mainFont_;
103     SearchRegexpType mainRegexpType_;
104     SearchRegexpType quickfindRegexpType_;
105     bool quickfindIncremental_;
106     bool pollingEnabled_;
107     uint32_t pollIntervalMs_;
108     bool loadLastSession_;
109 
110     // View settings
111     bool overviewVisible_;
112     bool lineNumbersVisibleInMain_;
113     bool lineNumbersVisibleInFiltered_;
114 
115     // Default settings for new views
116     bool searchAutoRefresh_;
117     bool searchIgnoreCase_;
118 };
119 
120 #endif
121