xref: /glogg/src/configuration.h (revision 3b104697d849ffe3af885a1684937240f00fa9ad)
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,
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     // "Advanced" settings
59     bool pollingEnabled() const
60     { return pollingEnabled_; }
61     void setPollingEnabled( bool enabled )
62     { pollingEnabled_ = enabled; }
63     uint32_t pollIntervalMs() const
64     { return pollIntervalMs_; }
65     void setPollIntervalMs( uint32_t interval )
66     { pollIntervalMs_ = interval; }
67     bool loadLastSession() const
68     { return loadLastSession_; }
69     void setLoadLastSession( bool enabled )
70     { loadLastSession_ = enabled; }
71 
72     // View settings
73     bool isOverviewVisible() const
74     { return overviewVisible_; }
75     void setOverviewVisible( bool isVisible )
76     { overviewVisible_ = isVisible; }
77     bool mainLineNumbersVisible() const
78     { return lineNumbersVisibleInMain_; }
79     bool filteredLineNumbersVisible() const
80     { return lineNumbersVisibleInFiltered_; }
81     void setMainLineNumbersVisible( bool lineNumbersVisible )
82     { lineNumbersVisibleInMain_ = lineNumbersVisible; }
83     void setFilteredLineNumbersVisible( bool lineNumbersVisible )
84     { lineNumbersVisibleInFiltered_ = lineNumbersVisible; }
85 
86     // Default settings for new views
87     bool isSearchAutoRefreshDefault() const
88     { return searchAutoRefresh_; }
89     void setSearchAutoRefreshDefault( bool auto_refresh )
90     { searchAutoRefresh_ = auto_refresh; }
91     bool isSearchIgnoreCaseDefault() const
92     { return searchIgnoreCase_; }
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