xref: /glogg/src/configuration.h (revision 702af59ea138e3124b906092de415e3601c74d3e)
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 
68     // View settings
69     bool isOverviewVisible() const
70     { return overviewVisible_; }
71     void setOverviewVisible( bool isVisible )
72     { overviewVisible_ = isVisible; }
73     bool mainLineNumbersVisible() const
74     { return lineNumbersVisibleInMain_; }
75     bool filteredLineNumbersVisible() const
76     { return lineNumbersVisibleInFiltered_; }
77     void setMainLineNumbersVisible( bool lineNumbersVisible )
78     { lineNumbersVisibleInMain_ = lineNumbersVisible; }
79     void setFilteredLineNumbersVisible( bool lineNumbersVisible )
80     { lineNumbersVisibleInFiltered_ = lineNumbersVisible; }
81 
82     // Default settings for new views
83     bool isSearchAutoRefreshDefault() const
84     { return searchAutoRefresh_; }
85     void setSearchAutoRefreshDefault( bool auto_refresh )
86     { searchAutoRefresh_ = auto_refresh; }
87     bool isSearchIgnoreCaseDefault() const
88     { return searchIgnoreCase_; }
89     void setSearchIgnoreCaseDefault( bool ignore_case )
90     { searchIgnoreCase_ = ignore_case; }
91 
92     // Reads/writes the current config in the QSettings object passed
93     virtual void saveToStorage( QSettings& settings ) const;
94     virtual void retrieveFromStorage( QSettings& settings );
95 
96   private:
97     // Configuration settings
98     QFont mainFont_;
99     SearchRegexpType mainRegexpType_;
100     SearchRegexpType quickfindRegexpType_;
101     bool quickfindIncremental_;
102     bool pollingEnabled_;
103     uint32_t pollIntervalMs_;
104 
105     // View settings
106     bool overviewVisible_;
107     bool lineNumbersVisibleInMain_;
108     bool lineNumbersVisibleInFiltered_;
109 
110     // Default settings for new views
111     bool searchAutoRefresh_;
112     bool searchIgnoreCase_;
113 };
114 
115 #endif
116