1 /*
2   SPDX-FileCopyrightText: 2000, 2001 Cornelius Schumacher <schumacher@kde.org>
3   SPDX-FileCopyrightText: 2010 Klarälvdalens Datakonsult AB, a KDAB Group company <info@kdab.net>
4   SPDX-FileContributor: Kevin Krammer <krake@kdab.com>
5 
6   SPDX-License-Identifier: GPL-2.0-or-later WITH Qt-Commercial-exception-1.0
7 */
8 #pragma once
9 
10 #include "eventview.h"
11 #include "eventviews_export.h"
12 
13 #include <KConfigSkeleton>
14 
15 #include <QTimeZone>
16 
17 #include <memory>
18 
19 namespace EventViews
20 {
21 class PrefsPrivate;
22 
23 class EVENTVIEWS_EXPORT Prefs
24 {
25 public:
26     /**
27       Creates an instance of Prefs with just base config
28     */
29     Prefs();
30 
31     /**
32       Creates an instance of Prefs with base config and application override config
33 
34       The passed @p appConfig will be queried for matching items whenever one of the
35       accessors is called. If one is found it is used for setting/getting the value
36       otherwise the one from the eventviews base config is used.
37     */
38     explicit Prefs(KCoreConfigSkeleton *appConfig);
39 
40     ~Prefs();
41 
42     void readConfig();
43     void writeConfig();
44 
45 public:
46     void setMarcusBainsShowSeconds(bool showSeconds);
47     Q_REQUIRED_RESULT bool marcusBainsShowSeconds() const;
48 
49     void setAgendaMarcusBainsLineLineColor(const QColor &color);
50     Q_REQUIRED_RESULT QColor agendaMarcusBainsLineLineColor() const;
51 
52     void setMarcusBainsEnabled(bool enabled);
53     Q_REQUIRED_RESULT bool marcusBainsEnabled() const;
54 
55     void setAgendaMarcusBainsLineFont(const QFont &font);
56     Q_REQUIRED_RESULT QFont agendaMarcusBainsLineFont() const;
57 
58     void setHourSize(int size);
59     Q_REQUIRED_RESULT int hourSize() const;
60 
61     void setDayBegins(const QDateTime &dateTime);
62     Q_REQUIRED_RESULT QDateTime dayBegins() const;
63 
64     void setWorkingHoursStart(const QDateTime &dateTime);
65     Q_REQUIRED_RESULT QDateTime workingHoursStart() const;
66 
67     void setWorkingHoursEnd(const QDateTime &dateTime);
68     Q_REQUIRED_RESULT QDateTime workingHoursEnd() const;
69 
70     void setSelectionStartsEditor(bool startEditor);
71     Q_REQUIRED_RESULT bool selectionStartsEditor() const;
72 
73     void setUseSystemColor(bool useSystemColor);
74     Q_REQUIRED_RESULT bool useSystemColor() const;
75 
76     void setAgendaGridWorkHoursBackgroundColor(const QColor &color);
77     Q_REQUIRED_RESULT QColor agendaGridWorkHoursBackgroundColor() const;
78 
79     void setAgendaGridHighlightColor(const QColor &color);
80     Q_REQUIRED_RESULT QColor agendaGridHighlightColor() const;
81 
82     void setAgendaGridBackgroundColor(const QColor &color);
83     Q_REQUIRED_RESULT QColor agendaGridBackgroundColor() const;
84 
85     void setEnableAgendaItemIcons(bool enable);
86     Q_REQUIRED_RESULT bool enableAgendaItemIcons() const;
87 
88     void setTodosUseCategoryColors(bool useColors);
89     Q_REQUIRED_RESULT bool todosUseCategoryColors() const;
90 
91     void setAgendaHolidaysBackgroundColor(const QColor &color) const;
92     Q_REQUIRED_RESULT QColor agendaHolidaysBackgroundColor() const;
93 
94     void setAgendaViewColors(int colors);
95     Q_REQUIRED_RESULT int agendaViewColors() const;
96 
97     void setAgendaViewFont(const QFont &font);
98     Q_REQUIRED_RESULT QFont agendaViewFont() const;
99 
100     void setMonthViewFont(const QFont &font);
101     Q_REQUIRED_RESULT QFont monthViewFont() const;
102 
103     Q_REQUIRED_RESULT QColor monthGridBackgroundColor() const;
104     void setMonthGridBackgroundColor(const QColor &color);
105 
106     Q_REQUIRED_RESULT QColor monthGridWorkHoursBackgroundColor() const;
107     void monthGridWorkHoursBackgroundColor(const QColor &color);
108 
109     void setMonthViewColors(int colors) const;
110     Q_REQUIRED_RESULT int monthViewColors() const;
111 
112     Q_REQUIRED_RESULT bool enableMonthItemIcons() const;
113     void setEnableMonthItemIcons(bool enable);
114 
115     Q_REQUIRED_RESULT bool showTimeInMonthView() const;
116     void setShowTimeInMonthView(bool show);
117 
118     Q_REQUIRED_RESULT bool showTodosMonthView() const;
119     void setShowTodosMonthView(bool show);
120 
121     Q_REQUIRED_RESULT bool showJournalsMonthView() const;
122     void setShowJournalsMonthView(bool show);
123 
124     Q_REQUIRED_RESULT bool fullViewMonth() const;
125     void setFullViewMonth(bool fullView);
126 
127     Q_REQUIRED_RESULT bool sortCompletedTodosSeparately() const;
128     void setSortCompletedTodosSeparately(bool sort);
129 
130     void setEnableToolTips(bool enable);
131     Q_REQUIRED_RESULT bool enableToolTips() const;
132 
133     void setShowTodosAgendaView(bool show);
134     Q_REQUIRED_RESULT bool showTodosAgendaView() const;
135 
136     void setAgendaTimeLabelsFont(const QFont &font);
137     Q_REQUIRED_RESULT QFont agendaTimeLabelsFont() const;
138 
139     KConfigSkeleton::ItemFont *fontItem(const QString &name) const;
140 
141     void setResourceColor(const QString &, const QColor &);
142     Q_REQUIRED_RESULT QColor resourceColor(const QString &);
143     Q_REQUIRED_RESULT QColor resourceColorKnown(const QString &) const;
144 
145     Q_REQUIRED_RESULT QTimeZone timeZone() const;
146 
147     Q_REQUIRED_RESULT QStringList timeScaleTimezones() const;
148     void setTimeScaleTimezones(const QStringList &list);
149 
150     Q_REQUIRED_RESULT QStringList selectedPlugins() const;
151     void setSelectedPlugins(const QStringList &);
152 
153     Q_REQUIRED_RESULT QStringList decorationsAtAgendaViewTop() const;
154     void setDecorationsAtAgendaViewTop(const QStringList &);
155 
156     Q_REQUIRED_RESULT QStringList decorationsAtAgendaViewBottom() const;
157     void setDecorationsAtAgendaViewBottom(const QStringList &);
158 
159     Q_REQUIRED_RESULT bool colorAgendaBusyDays() const;
160     void setColorAgendaBusyDays(bool enable);
161 
162     Q_REQUIRED_RESULT bool colorMonthBusyDays() const;
163     void setColorMonthBusyDays(bool enable);
164 
165     Q_REQUIRED_RESULT QColor viewBgBusyColor() const;
166     void setViewBgBusyColor(const QColor &);
167 
168     Q_REQUIRED_RESULT QColor holidayColor() const;
169     void setHolidayColor(const QColor &color);
170 
171     Q_REQUIRED_RESULT QColor agendaViewBackgroundColor() const;
172     void setAgendaViewBackgroundColor(const QColor &color);
173 
174     Q_REQUIRED_RESULT QColor workingHoursColor() const;
175     void setWorkingHoursColor(const QColor &color);
176 
177     Q_REQUIRED_RESULT QColor todoDueTodayColor() const;
178     void setTodoDueTodayColor(const QColor &color);
179 
180     Q_REQUIRED_RESULT QColor todoOverdueColor() const;
181     void setTodoOverdueColor(const QColor &color);
182 
183     Q_REQUIRED_RESULT QSet<EventViews::EventView::ItemIcon> agendaViewIcons() const;
184     void setAgendaViewIcons(const QSet<EventViews::EventView::ItemIcon> &icons);
185 
186     Q_REQUIRED_RESULT QSet<EventViews::EventView::ItemIcon> monthViewIcons() const;
187     void setMonthViewIcons(const QSet<EventViews::EventView::ItemIcon> &icons);
188 
189     void setFlatListTodo(bool);
190     Q_REQUIRED_RESULT bool flatListTodo() const;
191 
192     void setFullViewTodo(bool);
193     Q_REQUIRED_RESULT bool fullViewTodo() const;
194 
195     Q_REQUIRED_RESULT bool enableTodoQuickSearch() const;
196     void setEnableTodoQuickSearch(bool enable);
197 
198     Q_REQUIRED_RESULT bool enableQuickTodo() const;
199     void setEnableQuickTodo(bool enable);
200 
201     Q_REQUIRED_RESULT bool highlightTodos() const;
202     void setHighlightTodos(bool);
203 
204     void setFirstDayOfWeek(const int day);
205     Q_REQUIRED_RESULT int firstDayOfWeek() const;
206 
207     KConfig *config() const;
208 
209 private:
210     std::unique_ptr<PrefsPrivate> const d;
211 };
212 
213 using PrefsPtr = QSharedPointer<Prefs>;
214 }
215 
216