cmake: avoid de-duplication of user's CXXFLAGS
[quassel.git] / src / client / backlogsettings.cpp
1 /***************************************************************************
2  *   Copyright (C) 2005-2022 by the Quassel Project                        *
3  *   devel@quassel-irc.org                                                 *
4  *                                                                         *
5  *   This program is free software; you can redistribute it and/or modify  *
6  *   it under the terms of the GNU General Public License as published by  *
7  *   the Free Software Foundation; either version 2 of the License, or     *
8  *   (at your option) version 3.                                           *
9  *                                                                         *
10  *   This program is distributed in the hope that it will be useful,       *
11  *   but WITHOUT ANY WARRANTY; without even the implied warranty of        *
12  *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
13  *   GNU General Public License for more details.                          *
14  *                                                                         *
15  *   You should have received a copy of the GNU General Public License     *
16  *   along with this program; if not, write to the                         *
17  *   Free Software Foundation, Inc.,                                       *
18  *   51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.         *
19  ***************************************************************************/
20
21 #include "backlogsettings.h"
22
23 BacklogSettings::BacklogSettings()
24     : ClientSettings("Backlog")
25 {}
26
27 int BacklogSettings::requesterType() const
28 {
29     int _requesterType = localValue("RequesterType", BacklogRequester::AsNeeded).toInt();
30     if (_requesterType == BacklogRequester::GlobalUnread) {
31         // GlobalUnread is currently disabled; don't allow it to be used.  Reset to default instead.
32         _requesterType = BacklogRequester::AsNeeded;
33     }
34     return _requesterType;
35 }
36
37 void BacklogSettings::setRequesterType(int requesterType)
38 {
39     // This settings key is also used within ChatMonitorSettingsPage::ChatMonitorSettingsPage()
40     setLocalValue("RequesterType", requesterType);
41 }
42
43 int BacklogSettings::dynamicBacklogAmount() const
44 {
45     return localValue("DynamicBacklogAmount", 200).toInt();
46 }
47
48 void BacklogSettings::setDynamicBacklogAmount(int amount)
49 {
50     return setLocalValue("DynamicBacklogAmount", amount);
51 }
52
53 bool BacklogSettings::ensureBacklogOnBufferShow() const
54 {
55     // This settings key is also used within BufferWidget::BufferWidget()
56     return localValue("EnsureBacklogOnBufferShow", true).toBool();
57 }
58
59 void BacklogSettings::setEnsureBacklogOnBufferShow(bool enabled)
60 {
61     return setLocalValue("EnsureBacklogOnBufferShow", enabled);
62 }
63
64 int BacklogSettings::fixedBacklogAmount() const
65 {
66     return localValue("FixedBacklogAmount", 500).toInt();
67 }
68
69 void BacklogSettings::setFixedBacklogAmount(int amount)
70 {
71     return setLocalValue("FixedBacklogAmount", amount);
72 }
73
74 int BacklogSettings::globalUnreadBacklogLimit() const
75 {
76     return localValue("GlobalUnreadBacklogLimit", 5000).toInt();
77 }
78
79 void BacklogSettings::setGlobalUnreadBacklogLimit(int limit)
80 {
81     return setLocalValue("GlobalUnreadBacklogLimit", limit);
82 }
83
84 int BacklogSettings::globalUnreadBacklogAdditional() const
85 {
86     return localValue("GlobalUnreadBacklogAdditional", 100).toInt();
87 }
88
89 void BacklogSettings::setGlobalUnreadBacklogAdditional(int additional)
90 {
91     return setLocalValue("GlobalUnreadBacklogAdditional", additional);
92 }
93
94 int BacklogSettings::perBufferUnreadBacklogLimit() const
95 {
96     return localValue("PerBufferUnreadBacklogLimit", 200).toInt();
97 }
98
99 void BacklogSettings::setPerBufferUnreadBacklogLimit(int limit)
100 {
101     return setLocalValue("PerBufferUnreadBacklogLimit", limit);
102 }
103
104 int BacklogSettings::perBufferUnreadBacklogAdditional() const
105 {
106     return localValue("PerBufferUnreadBacklogAdditional", 50).toInt();
107 }
108
109 void BacklogSettings::setPerBufferUnreadBacklogAdditional(int additional)
110 {
111     return setLocalValue("PerBufferUnreadBacklogAdditional", additional);
112 }
113
114 int BacklogSettings::asNeededLegacyBacklogAmount() const
115 {
116     // Mimic FixedBacklogAmount defaults.  This is only used on cores lacking
117     // Feature::BufferActivitySync.
118     return localValue("AsNeededLegacyBacklogAmount", 500).toInt();
119 }
120
121 void BacklogSettings::setAsNeededLegacyBacklogAmount(int amount)
122 {
123     return setLocalValue("AsNeededLegacyBacklogAmount", amount);
124 }