setwrapper.h 7.86 KB
Newer Older
1
/*
2
 * Copyright (C) 2014-2018 CZ.NIC
3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23
 *
 * This program is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program. If not, see <http://www.gnu.org/licenses/>.
 *
 * In addition, as a special exception, the copyright holders give
 * permission to link the code of portions of this program with the
 * OpenSSL library under certain conditions as described in each
 * individual source file, and distribute linked combinations including
 * the two.
 */

24
#pragma once
25 26

#include <QObject>
27
#include <QString>
28

29 30
class AccountListModel; /* Forward declaration. */

31 32 33 34 35 36 37 38 39 40 41 42 43
/*
 * This class provide wrapper between
 * global settings class and QML settings page.
 * We need signal and slots for sending settings to/from QML page.
 * This object is initialized in main.cpp and register to QML.
 */
class GlobalSettingsQmlWrapper : public QObject {
    Q_OBJECT

public:
	/*!
	 * @brief Constructor.
	 */
Karel Slaný's avatar
Karel Slaný committed
44
	explicit GlobalSettingsQmlWrapper(QObject *parent = Q_NULLPTR);
45 46

	/*!
47 48 49
	 * @brief Get application version string.
	 *
	 * @return Application version string.
50
	*/
51
	Q_INVOKABLE
52
	QString appVersion(void) const;
53 54

	/*!
55
	 * @brief Get attachments life value from global settings.
56
	 *
57 58
	 * @return Attachments life value.
	*/
59
	Q_INVOKABLE
60
	int attachmentLifeDays(void) const;
61

62
	/*!
63 64 65 66
	 * @brief Get download complete messages from global settings.
	 *
	 * @return True if it is enabled.
	*/
67
	Q_INVOKABLE
68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124
	bool downloadCompleteMsgs(void) const;

	/*!
	 * @brief Get download only new messages from global settings.
	 *
	 * @return True if it is enabled.
	*/
	Q_INVOKABLE
	bool downloadOnlyNewMsgs(void) const;

	/*!
	 * @brief Get database location from global settings.
	 *
	 * @return Database location string.
	*/
	Q_INVOKABLE
	QString dbPath(void) const;

	/*!
	 * @brief Get font size value from global settings.
	 *
	 * @return Font size value.
	*/
	Q_INVOKABLE
	int fontSize(void) const;

	/*!
	 * @brief Get language string from global settings.
	 *
	 * @return Language string.
	*/
	Q_INVOKABLE
	QString language(void) const;

	/*!
	 * @brief Get message life from global settings.
	 *
	 * @return Message life value.
	*/
	Q_INVOKABLE
	int messageLifeDays(void) const;

	/*!
	 * @brief Get zfo database size from global settings.
	 *
	 * @return Zfo db size value.
	*/
	Q_INVOKABLE
	int zfoDbSizeMBs(void) const;

	/*!
	 * @brief Set attachments life value to global settings.
	 *
	 * @param[in] attachmentLifeDays Attachments life value.
	*/
	Q_INVOKABLE
	void setAttachmentLifeDays(int attachmentLifeDays);
125

126
	/*!
127
	 * @brief Set download complete messages to global settings.
128
	 *
129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153
	 * @param[in] downloadCompleteMsgs True if it is enabled.
	*/
	Q_INVOKABLE
	void setDownloadCompleteMsgs(bool downloadCompleteMsgs);

	/*!
	 * @brief Set download only new messages to global settings.
	 *
	 * @param[in] downloadOnlyNewMsgs True if it is enabled.
	*/
	Q_INVOKABLE
	void setDownloadOnlyNewMsgs(bool downloadOnlyNewMsgs);

	/*!
	 * @brief Set new database location to global settings.
	 *
	 * @param[in] dbLocation New database location string.
	*/
	Q_INVOKABLE
	void setDbPath(const QString &dbLocation);

	/*!
	 * @brief Set font size to global settings.
	 *
	 * @param[in] fontSize Font size value.
154
	 */
155
	Q_INVOKABLE
156
	void setFontSize(int fontSize);
157 158

	/*!
159
	 * @brief Set language to global settings.
160
	 *
161
	 * @param[in] language Language identificator string.
162
	 */
163
	Q_INVOKABLE
164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180
	void setLanguage(const QString &language);

	/*!
	 * @brief Set messages life value to global settings.
	 *
	 * @param[in] messageLifeDays Messages life value.
	*/
	Q_INVOKABLE
	void setMessageLifeDays(int messageLifeDays);

	/*!
	 * @brief Set zfo database size to global settings.
	 *
	 * @param[in] zfoDbSizeMBs Zfo database size value.
	*/
	Q_INVOKABLE
	void setZfoDbSizeMBs(int zfoDbSizeMBs);
181 182

	/*!
183
	 * @brief Show set default database location button.
184
	 *
185
	 * @return True if show button.
186
	 */
187
	Q_INVOKABLE
188 189 190 191 192 193 194
	bool showDefaultButton(void) const;

	/*!
	 * @brief Return current PIN value.
	 */
	Q_INVOKABLE
	QString pinValue(void) const;
195 196 197

	/*!
	 * @brief Save PIN settings from QML.
198
	 *
199
	 * @param[in] pinValue Pin string.
200
	 */
201 202
	Q_INVOKABLE
	void updatePinSettings(const QString &pinValue);
203 204 205

	/*!
	 * @brief Verify PIN entered by user and emit signal with result.
206
	 *
207
	 * @param[in] pinValue Pin string.
208
	 */
209 210
	Q_INVOKABLE
	void verifyPin(const QString &pinValue);
211

212 213 214 215 216 217
	/*!
	 * @brief Returns true if explicit clipboard operations should be used.
	 */
	Q_INVOKABLE
	bool useExplicitClipboardOperations(void) const;

218 219
	/*!
	 * @brief Returns new database location string to QML.
220
	 *
221 222
	 * @param[in] currentLocation Current databases location.
	 * @param[in] setDefaultLocation Default databases location.
223 224 225 226 227
	 */
	Q_INVOKABLE
	QString changeDbPath(const QString &currentLocation,
	    bool setDefaultLocation);

228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243
	/*!
	 * @brief Get inactivity timeout length.
	 *
	 * @return Inactivity interval in seconds.
	 */
	Q_INVOKABLE
	int inactivityInterval(void) const;

	/*!
	 * @brief Set inactivity timeout length.
	 *
	 * @param[in] secs Inactivity interval length in seconds.
	 */
	Q_INVOKABLE
	void setInactivityInterval(int secs);

244 245 246 247 248 249
	/*!
	 * @brief Set last update time to current time.
	 */
	Q_INVOKABLE static
	void setLastUpdateToNow(void);

250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281
	/*!
	 * @brief Get records management url string.
	 *
	 * @return Records management url string.
	 */
	Q_INVOKABLE
	QString rmUrl(void) const;

	/*!
	 * @brief Set records management url string.
	 *
	 * @param[in] rmUrl records management url string.
	 */
	Q_INVOKABLE
	void setRmUrl(const QString &rmUrl);

	/*!
	 * @brief Get records management token string.
	 *
	 * @return Records management token string.
	 */
	Q_INVOKABLE
	QString rmToken(void) const;

	/*!
	 * @brief Set records management token string.
	 *
	 * @param[in] rmToken records management token string.
	 */
	Q_INVOKABLE
	void setRmToken(const QString &rmToken);

282 283
	/*!
	 * @brief Gathers all settings and stores them into configuration file.
284
	 *
285 286 287 288 289 290 291
	 * @note QML is bitching about unknown method parameter type
	 *     const AccountListModel* when passing a model via multiple
	 *     variables. That's why there is a method that directly accepts
	 *     a variant.
	 *
	 * @param[in,out] acntModelVariant QVariant holding account model
	 *                                 to be read.
292 293
	 */
	Q_INVOKABLE static
294 295 296 297 298 299 300 301
	void saveAllSettings(const QVariant &acntModelVariant);

	/*!
	 * @brief Gathers all settings and stores them into configuration file.
	 *
	 * @param[in] accountModel Account model to take data from.
	 */
	static
302
	void saveAllSettings(const AccountListModel *accountModel);
303

304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331
	/*!
	 * @brief Return debug verbosity level.
	 */
	Q_INVOKABLE
	int debugVerbosityLevel(void) const;

	/*!
	 * @brief Return log verbosity level.
	 */
	Q_INVOKABLE
	int logVerbosityLevel(void) const;

	/*!
	 * @brief Set debug verbosity level.
	 *
	 * @param[in] dVL log verbosity level.
	 */
	Q_INVOKABLE
	void setDebugVerbosityLevel(int dVL);

	/*!
	 * @brief Set log verbosity level.
	 *
	 * @param[in] lVL log verbosity level.
	 */
	Q_INVOKABLE
	void setLogVerosityLevel(int lVL);

332
signals:
333 334

	/*!
335
	 * @brief Send PIN verification result to QML.
336
	 *
337
	 * @param[in] success PIN comparison notification to QML.
338 339 340
	 */
	void sendPinReply(bool success);

341 342 343
	/*!
	 * @brief Set new statusbar text and active busy indicator to QML.
	 *
344 345
	 * @param[in] txt Text message for statusbar.
	 * @param[in] busy True means the statusbar busy indicator is active
346 347 348
	 *                   and shown, false = disabled and hidden
	 */
	void statusBarTextChanged(QString txt, bool busy);
349
};