1/*
2 * Copyright (C) by Klaas Freitag <freitag@owncloud.com>
3 *
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation; either version 2 of the License, or
7 * (at your option) any later version.
8 *
9 * This program is distributed in the hope that it will be useful, but
10 * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
11 * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
12 * for more details.
13 */
14
15#ifndef _THEME_H
16#define _THEME_H
17
18#include <QObject>
19#include "syncresult.h"
20
21class QIcon;
22class QString;
23class QObject;
24class QPixmap;
25class QColor;
26class QPaintDevice;
27
28namespace OCC {
29
30class SyncResult;
31
32/**
33 * @brief The Theme class
34 * @ingroup libsync
35 */
36class OWNCLOUDSYNC_EXPORT Theme : public QObject
37{
38 Q_OBJECT
39public:
40 enum CustomMediaType {
41 oCSetupTop, // ownCloud connect page
42 oCSetupSide,
43 oCSetupBottom,
44 oCSetupResultTop // ownCloud connect result page
45 };
46
47 /* returns a singleton instance. */
48 static Theme *instance();
49
50 ~Theme();
51
52 /**
53 * @brief appNameGUI - Human readable application name.
54 *
55 * Use and redefine this if the human readable name contains spaces,
56 * special chars and such.
57 *
58 * By default, the name is derived from the APPLICATION_NAME
59 * cmake variable.
60 *
61 * @return QString with human readable app name.
62 */
63 virtual QString appNameGUI() const;
64
65 /**
66 * @brief appName - Application name (short)
67 *
68 * Use and redefine this as an application name. Keep it straight as
69 * it is used for config files etc. If you need a more sophisticated
70 * name in the GUI, redefine appNameGUI.
71 *
72 * By default, the name is derived from the APPLICATION_SHORTNAME
73 * cmake variable, and should be the same. This method is only
74 * reimplementable for legacy reasons.
75 *
76 * Warning: Do not modify this value, as many things, e.g. settings
77 * depend on it! You most likely want to modify \ref appNameGUI().
78 *
79 * @return QString with app name.
80 */
81 virtual QString appName() const;
82
83 /**
84 * @brief configFileName
85 * @return the name of the config file.
86 */
87 virtual QString configFileName() const;
88
89#ifndef TOKEN_AUTH_ONLY
90 static QString hidpiFileName(const QString &fileName, QPaintDevice *dev = 0);
91
92 /**
93 * get an sync state icon
94 */
95 virtual QIcon syncStateIcon(SyncResult::Status, bool sysTray = false, bool sysTrayMenuVisible = false) const;
96
97 virtual QIcon folderDisabledIcon() const;
98 virtual QIcon folderOfflineIcon(bool sysTray = false, bool sysTrayMenuVisible = false) const;
99 virtual QIcon applicationIcon() const;
100#endif
101
102 virtual QString statusHeaderText(SyncResult::Status) const;
103 virtual QString version() const;
104
105 /**
106 * Characteristics: bool if more than one sync folder is allowed
107 */
108 virtual bool singleSyncFolder() const;
109
110 /**
111 * When true, client works with multiple accounts.
112 */
113 virtual bool multiAccount() const;
114
115 /**
116 * URL to documentation.
117 *
118 * This is opened in the browser when the "Help" action is selected from the tray menu.
119 *
120 * If the function is overridden to return an empty string the action is removed from
121 * the menu.
122 *
123 * Defaults to ownCloud's client documentation website.
124 */
125 virtual QString helpUrl() const;
126
127 /**
128 * The url to use for showing help on conflicts.
129 *
130 * If the function is overridden to return an empty string no help link will be shown.
131 *
132 * Defaults to helpUrl() + "conflicts.html", which is a page in ownCloud's client
133 * documentation website. If helpUrl() is empty, this function will also return the
134 * empty string.
135 */
136 virtual QString conflictHelpUrl() const;
137
138 /**
139 * Setting a value here will pre-define the server url.
140 *
141 * The respective UI controls will be disabled
142 */
143 virtual QString overrideServerUrl() const;
144
145 /**
146 * This is only usefull when previous version had a different overrideServerUrl
147 * with a different auth type in that case You should then specify "http" or "shibboleth".
148 * Normaly this should be left empty.
149 */
150 virtual QString forceConfigAuthType() const;
151
152 /**
153 * The default folder name without path on the server at setup time.
154 */
155 virtual QString defaultServerFolder() const;
156
157 /**
158 * The default folder name without path on the client side at setup time.
159 */
160 virtual QString defaultClientFolder() const;
161
162 /**
163 * Override to encforce a particular locale, i.e. "de" or "pt_BR"
164 */
165 virtual QString enforcedLocale() const { return QString(); }
166
167 /** colored, white or black */
168 QString systrayIconFlavor(bool mono, bool sysTrayMenuVisible = false) const;
169
170#ifndef TOKEN_AUTH_ONLY
171 /**
172 * Override to use a string or a custom image name.
173 * The default implementation will try to look up
174 * :/client/theme/<type>.png
175 */
176 virtual QVariant customMedia(CustomMediaType type);
177
178 /** @return color for the setup wizard */
179 virtual QColor wizardHeaderTitleColor() const;
180
181 /** @return color for the setup wizard. */
182 virtual QColor wizardHeaderBackgroundColor() const;
183
184 /** @return logo for the setup wizard. */
185 virtual QPixmap wizardHeaderLogo() const;
186
187 /**
188 * The default implementation creates a
189 * background based on
190 * \ref wizardHeaderTitleColor().
191 *
192 * @return banner for the setup wizard.
193 */
194 virtual QPixmap wizardHeaderBanner() const;
195#endif
196
197 /**
198 * The SHA sum of the released git commit
199 */
200 QString gitSHA1() const;
201
202 /**
203 * About dialog contents
204 */
205 virtual QString about() const;
206
207 /**
208 * Define if the systray icons should be using mono design
209 */
210 void setSystrayUseMonoIcons(bool mono);
211
212 /**
213 * Retrieve wether to use mono icons for systray
214 */
215 bool systrayUseMonoIcons() const;
216
217 /**
218 * Check if mono icons are available
219 */
220 bool monoIconsAvailable() const;
221
222 /**
223 * @brief Where to check for new Updates.
224 */
225 virtual QString updateCheckUrl() const;
226
227 /**
228 * When true, the setup wizard will show the selective sync dialog by default and default
229 * to nothing selected
230 */
231 virtual bool wizardSelectiveSyncDefaultNothing() const;
232
233 /**
234 * Default option for the newBigFolderSizeLimit.
235 * Size in MB of the maximum size of folder before we ask the confirmation.
236 * Set -1 to never ask confirmation. 0 to ask confirmation for every folder.
237 **/
238 virtual qint64 newBigFolderSizeLimit() const;
239
240 /**
241 * Hide the checkbox that says "Ask for confirmation before synchronizing folders larger than X MB"
242 * in the account wizard
243 */
244 virtual bool wizardHideFolderSizeLimitCheckbox() const;
245 /**
246 * Hide the checkbox that says "Ask for confirmation before synchronizing external storages"
247 * in the account wizard
248 */
249 virtual bool wizardHideExternalStorageConfirmationCheckbox() const;
250
251 /**
252 * Alternative path on the server that provides access to the webdav capabilities
253 *
254 * Attention: Make sure that this string does NOT have a leading slash and that
255 * it has a trailing slash, for example "remote.php/webdav/".
256 */
257 virtual QString webDavPath() const;
258 virtual QString webDavPathNonShib() const;
259
260 /**
261 * @brief Sharing options
262 *
263 * Allow link sharing and or user/group sharing
264 */
265 virtual bool linkSharing() const;
266 virtual bool userGroupSharing() const;
267
268 /**
269 * If this returns true, the user cannot configure the proxy in the network settings.
270 * The proxy settings will be disabled in the configuration dialog.
271 * Default returns false.
272 */
273 virtual bool forceSystemNetworkProxy() const;
274
275 /**
276 * @brief How to handle the userID
277 *
278 * @value UserIDUserName Wizard asks for user name as ID
279 * @value UserIDEmail Wizard asks for an email as ID
280 * @value UserIDCustom Specify string in \ref customUserID
281 */
282 enum UserIDType { UserIDUserName = 0,
283 UserIDEmail,
284 UserIDCustom };
285
286 /** @brief What to display as the userID (e.g. in the wizards)
287 *
288 * @return UserIDType::UserIDUserName, unless reimplemented
289 */
290 virtual UserIDType userIDType() const;
291
292 /**
293 * @brief Allows to customize the type of user ID (e.g. user name, email)
294 *
295 * @note This string cannot be translated, but is still useful for
296 * referencing brand name IDs (e.g. "ACME ID", when using ACME.)
297 *
298 * @return An empty string, unless reimplemented
299 */
300 virtual QString customUserID() const;
301
302 /**
303 * @brief Demo string to be displayed when no text has been
304 * entered for the user id (e.g. mylogin@company.com)
305 *
306 * @return An empty string, unless reimplemented
307 */
308 virtual QString userIDHint() const;
309
310 /**
311 * @brief Postfix that will be enforced in a URL. e.g.
312 * ".myhosting.com".
313 *
314 * @return An empty string, unless reimplemented
315 */
316 virtual QString wizardUrlPostfix() const;
317
318 /**
319 * @brief String that will be shown as long as no text has been entered by the user.
320 *
321 * @return An empty string, unless reimplemented
322 */
323 virtual QString wizardUrlHint() const;
324
325 /**
326 * @brief the server folder that should be queried for the quota information
327 *
328 * This can be configured to show the quota infromation for a different
329 * folder than the root. This is the folder on which the client will do
330 * PROPFIND calls to get "quota-available-bytes" and "quota-used-bytes"
331 *
332 * Defaults: "/"
333 */
334 virtual QString quotaBaseFolder() const;
335
336 /**
337 * The OAuth client_id, secret pair.
338 * Note that client that change these value cannot connect to un-branded owncloud servers.
339 */
340 virtual QString oauthClientId() const;
341 virtual QString oauthClientSecret() const;
342
343 /**
344 * @brief What should be output for the --version command line switch.
345 *
346 * By default, it's a combination of appName(), version(), the GIT SHA1 and some
347 * important dependency versions.
348 */
349 virtual QString versionSwitchOutput() const;
350
351protected:
352#ifndef TOKEN_AUTH_ONLY
353 QIcon themeIcon(const QString &name, bool sysTray = false, bool sysTrayMenuVisible = false) const;
354#endif
355 Theme();
356
357signals:
358 void systrayUseMonoIconsChanged(bool);
359
360private:
361 Theme(Theme const &);
362 Theme &operator=(Theme const &);
363
364 static Theme *_instance;
365 bool _mono;
366#ifndef TOKEN_AUTH_ONLY
367 mutable QHash<QString, QIcon> _iconCache;
368#endif
369};
370}
371#endif // _THEME_H
372