1 /* ============================================================
2 *
3 * This file is a part of digiKam project
4 * https://www.digikam.org
5 *
6 * Date : 2003-16-10
7 * Description : application settings interface
8 *
9 * Copyright (C) 2003-2004 by Renchi Raju <renchi dot raju at gmail dot com>
10 * Copyright (C) 2003-2021 by Gilles Caulier <caulier dot gilles at gmail dot com>
11 * Copyright (C) 2007 by Arnd Baecker <arnd dot baecker at web dot de>
12 * Copyright (C) 2014 by Mohamed_Anwer <m_dot_anwer at gmx dot com>
13 * Copyright (C) 2014 by Veaceslav Munteanu <veaceslav dot munteanu90 at gmail dot com>
14 * Copyright (C) 2017 by Simon Frei <freisim93 at gmail dot com>
15 *
16 * This program is free software; you can redistribute it
17 * and/or modify it under the terms of the GNU General
18 * Public License as published by the Free Software Foundation;
19 * either version 2, or (at your option)
20 * any later version.
21 *
22 * This program is distributed in the hope that it will be useful,
23 * but WITHOUT ANY WARRANTY; without even the implied warranty of
24 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
25 * GNU General Public License for more details.
26 *
27 * ============================================================ */
28
29 #include "applicationsettings_p.h"
30
31 namespace Digikam
32 {
33
getUpdateType() const34 int ApplicationSettings::getUpdateType() const
35 {
36 return d->updateType;
37 }
38
setUpdateType(int type)39 void ApplicationSettings::setUpdateType(int type)
40 {
41 d->updateType = type;
42 }
43
getUpdateWithDebug() const44 bool ApplicationSettings::getUpdateWithDebug() const
45 {
46 return d->updateWithDebug;
47 }
48
setUpdateWithDebug(bool dbg)49 void ApplicationSettings::setUpdateWithDebug(bool dbg)
50 {
51 d->updateWithDebug = dbg;
52 }
53
setCurrentTheme(const QString & theme)54 void ApplicationSettings::setCurrentTheme(const QString& theme)
55 {
56 d->currentTheme = theme;
57 }
58
getCurrentTheme() const59 QString ApplicationSettings::getCurrentTheme() const
60 {
61 return d->currentTheme;
62 }
63
setShowSplashScreen(bool val)64 void ApplicationSettings::setShowSplashScreen(bool val)
65 {
66 d->showSplash = val;
67 }
68
getShowSplashScreen() const69 bool ApplicationSettings::getShowSplashScreen() const
70 {
71 return d->showSplash;
72 }
73
setSidebarTitleStyle(DMultiTabBar::TextStyle style)74 void ApplicationSettings::setSidebarTitleStyle(DMultiTabBar::TextStyle style)
75 {
76 d->sidebarTitleStyle = style;
77 }
78
getSidebarTitleStyle() const79 DMultiTabBar::TextStyle ApplicationSettings::getSidebarTitleStyle() const
80 {
81 return d->sidebarTitleStyle;
82 }
83
setUseTrash(bool val)84 void ApplicationSettings::setUseTrash(bool val)
85 {
86 d->useTrash = val;
87 }
88
getUseTrash() const89 bool ApplicationSettings::getUseTrash() const
90 {
91 return d->useTrash;
92 }
93
setShowTrashDeleteDialog(bool val)94 void ApplicationSettings::setShowTrashDeleteDialog(bool val)
95 {
96 d->showTrashDeleteDialog = val;
97 }
98
getShowTrashDeleteDialog() const99 bool ApplicationSettings::getShowTrashDeleteDialog() const
100 {
101 return d->showTrashDeleteDialog;
102 }
103
setShowPermanentDeleteDialog(bool val)104 void ApplicationSettings::setShowPermanentDeleteDialog(bool val)
105 {
106 d->showPermanentDeleteDialog = val;
107 }
108
getShowPermanentDeleteDialog() const109 bool ApplicationSettings::getShowPermanentDeleteDialog() const
110 {
111 return d->showPermanentDeleteDialog;
112 }
113
setApplySidebarChangesDirectly(bool val)114 void ApplicationSettings::setApplySidebarChangesDirectly(bool val)
115 {
116 d->sidebarApplyDirectly = val;
117 }
118
getApplySidebarChangesDirectly() const119 bool ApplicationSettings::getApplySidebarChangesDirectly() const
120 {
121 return d->sidebarApplyDirectly;
122 }
123
setUseNativeFileDialog(bool val)124 void ApplicationSettings::setUseNativeFileDialog(bool val)
125 {
126 d->useNativeFileDialog = val;
127 }
128
getUseNativeFileDialog() const129 bool ApplicationSettings::getUseNativeFileDialog() const
130 {
131 return d->useNativeFileDialog;
132 }
133
setDrawFramesToGrouped(bool val)134 void ApplicationSettings::setDrawFramesToGrouped(bool val)
135 {
136 d->drawFramesToGrouped = val;
137 }
138
getDrawFramesToGrouped() const139 bool ApplicationSettings::getDrawFramesToGrouped() const
140 {
141 return d->drawFramesToGrouped;
142 }
143
setExpandNewCurrentItem(bool val)144 void ApplicationSettings::setExpandNewCurrentItem(bool val)
145 {
146 d->expandNewCurrentItem = val;
147 }
148
getExpandNewCurrentItem() const149 bool ApplicationSettings::getExpandNewCurrentItem() const
150 {
151 return d->expandNewCurrentItem;
152 }
153
setScrollItemToCenter(bool val)154 void ApplicationSettings::setScrollItemToCenter(bool val)
155 {
156 d->scrollItemToCenter = val;
157 }
158
getScrollItemToCenter() const159 bool ApplicationSettings::getScrollItemToCenter() const
160 {
161 return d->scrollItemToCenter;
162 }
163
setShowOnlyPersonTagsInPeopleSidebar(bool val)164 void ApplicationSettings::setShowOnlyPersonTagsInPeopleSidebar(bool val)
165 {
166 d->showOnlyPersonTagsInPeopleSidebar = val;
167 }
168
showOnlyPersonTagsInPeopleSidebar() const169 bool ApplicationSettings::showOnlyPersonTagsInPeopleSidebar() const
170 {
171 return d->showOnlyPersonTagsInPeopleSidebar;
172 }
173
setStringComparisonType(ApplicationSettings::StringComparisonType val)174 void ApplicationSettings::setStringComparisonType(ApplicationSettings::StringComparisonType val)
175 {
176 d->stringComparisonType = val;
177 }
178
getStringComparisonType() const179 ApplicationSettings::StringComparisonType ApplicationSettings::getStringComparisonType() const
180 {
181 return d->stringComparisonType;
182 }
183
isStringTypeNatural() const184 bool ApplicationSettings::isStringTypeNatural() const
185 {
186 return (d->stringComparisonType == ApplicationSettings::Natural);
187 }
188
setVersionManagerSettings(const VersionManagerSettings & settings)189 void ApplicationSettings::setVersionManagerSettings(const VersionManagerSettings& settings)
190 {
191 d->versionSettings = settings;
192 }
193
getVersionManagerSettings() const194 VersionManagerSettings ApplicationSettings::getVersionManagerSettings() const
195 {
196 return d->versionSettings;
197 }
198
getFaceDetectionAccuracy() const199 double ApplicationSettings::getFaceDetectionAccuracy() const
200 {
201 return d->faceDetectionAccuracy;
202 }
203
setFaceDetectionAccuracy(double value)204 void ApplicationSettings::setFaceDetectionAccuracy(double value)
205 {
206 d->faceDetectionAccuracy = value;
207 }
208
getFaceDetectionYoloV3() const209 bool ApplicationSettings::getFaceDetectionYoloV3() const
210 {
211 return d->faceDetectionYoloV3;
212 }
213
setFaceDetectionYoloV3(bool yolo)214 void ApplicationSettings::setFaceDetectionYoloV3(bool yolo)
215 {
216 d->faceDetectionYoloV3 = yolo;
217 }
218
setApplicationStyle(const QString & style)219 void ApplicationSettings::setApplicationStyle(const QString& style)
220 {
221 if (d->applicationStyle.compare(style, Qt::CaseInsensitive) != 0)
222 {
223 d->applicationStyle = style;
224 qApp->setStyle(d->applicationStyle);
225 qApp->style()->polish(qApp);
226 qCDebug(DIGIKAM_GENERAL_LOG) << "Switch to widget style: " << d->applicationStyle;
227 }
228 }
229
getApplicationStyle() const230 QString ApplicationSettings::getApplicationStyle() const
231 {
232 return d->applicationStyle;
233 }
234
setIconTheme(const QString & theme)235 void ApplicationSettings::setIconTheme(const QString& theme)
236 {
237 d->applicationIcon = theme;
238 }
239
getIconTheme() const240 QString ApplicationSettings::getIconTheme() const
241 {
242 return d->applicationIcon;
243 }
244
setShowThumbbar(bool val)245 void ApplicationSettings::setShowThumbbar(bool val)
246 {
247 d->showThumbbar = val;
248 }
249
getShowThumbbar() const250 bool ApplicationSettings::getShowThumbbar() const
251 {
252 return d->showThumbbar;
253 }
254
setRatingFilterCond(int val)255 void ApplicationSettings::setRatingFilterCond(int val)
256 {
257 d->ratingFilterCond = val;
258 }
259
getRatingFilterCond() const260 int ApplicationSettings::getRatingFilterCond() const
261 {
262 return d->ratingFilterCond;
263 }
264
setScanAtStart(bool val)265 void ApplicationSettings::setScanAtStart(bool val)
266 {
267 d->scanAtStart = val;
268 }
269
getScanAtStart() const270 bool ApplicationSettings::getScanAtStart() const
271 {
272 return d->scanAtStart;
273 }
274
setCleanAtStart(bool val)275 void ApplicationSettings::setCleanAtStart(bool val)
276 {
277 d->cleanAtStart = val;
278 }
279
getCleanAtStart() const280 bool ApplicationSettings::getCleanAtStart() const
281 {
282 return d->cleanAtStart;
283 }
284
setDatabaseDirSetAtCmd(bool val)285 void ApplicationSettings::setDatabaseDirSetAtCmd(bool val)
286 {
287 d->databaseDirSetAtCmd = val;
288 }
289
getDatabaseDirSetAtCmd() const290 bool ApplicationSettings::getDatabaseDirSetAtCmd() const
291 {
292 return d->databaseDirSetAtCmd;
293 }
294
setMinimumSimilarityBound(int val)295 void ApplicationSettings::setMinimumSimilarityBound(int val)
296 {
297 d->minimumSimilarityBound = val;
298 }
299
getMinimumSimilarityBound() const300 int ApplicationSettings::getMinimumSimilarityBound() const
301 {
302 return d->minimumSimilarityBound;
303 }
304
setDuplicatesSearchLastMinSimilarity(int val)305 void ApplicationSettings::setDuplicatesSearchLastMinSimilarity(int val)
306 {
307 d->duplicatesSearchLastMinSimilarity = val;
308 }
309
getDuplicatesSearchLastMinSimilarity() const310 int ApplicationSettings::getDuplicatesSearchLastMinSimilarity() const
311 {
312 return d->duplicatesSearchLastMinSimilarity;
313 }
314
setDuplicatesSearchLastMaxSimilarity(int val)315 void ApplicationSettings::setDuplicatesSearchLastMaxSimilarity(int val)
316 {
317 d->duplicatesSearchLastMaxSimilarity = val;
318 }
319
getDuplicatesSearchLastMaxSimilarity() const320 int ApplicationSettings::getDuplicatesSearchLastMaxSimilarity() const
321 {
322 return d->duplicatesSearchLastMaxSimilarity;
323 }
324
setDuplicatesAlbumTagRelation(int val)325 void ApplicationSettings::setDuplicatesAlbumTagRelation(int val)
326 {
327 d->duplicatesSearchLastAlbumTagRelation = val;
328 }
329
getDuplicatesAlbumTagRelation() const330 int ApplicationSettings::getDuplicatesAlbumTagRelation() const
331 {
332 return d->duplicatesSearchLastAlbumTagRelation;
333 }
334
335
setDuplicatesSearchRestrictions(int val)336 void ApplicationSettings::setDuplicatesSearchRestrictions(int val)
337 {
338 d->duplicatesSearchLastRestrictions = val;
339 }
340
getDuplicatesSearchRestrictions() const341 int ApplicationSettings::getDuplicatesSearchRestrictions() const
342 {
343 return d->duplicatesSearchLastRestrictions;
344 }
345
setGroupingOperateOnAll(ApplicationSettings::OperationType type,ApplicationSettings::ApplyToEntireGroup applyAll)346 void ApplicationSettings::setGroupingOperateOnAll(ApplicationSettings::OperationType type,
347 ApplicationSettings::ApplyToEntireGroup applyAll)
348 {
349 if (!d->groupingOperateOnAll.contains(type))
350 {
351 throw std::invalid_argument("ApplicationSettings::setGroupingOperateOnAll: Invalid operation type.");
352 }
353
354 d->groupingOperateOnAll[type] = applyAll;
355 return;
356 }
357
getGroupingOperateOnAll(ApplicationSettings::OperationType type) const358 ApplicationSettings::ApplyToEntireGroup ApplicationSettings::getGroupingOperateOnAll(
359 ApplicationSettings::OperationType type) const
360 {
361 if (!d->groupingOperateOnAll.contains(type))
362 {
363 throw std::invalid_argument("ApplicationSettings::getGroupingOperateOnAll: Invalid operation type.");
364 }
365
366 if (type == ApplicationSettings::Unspecified)
367 {
368 return ApplicationSettings::No;
369 }
370
371 return d->groupingOperateOnAll[type];
372 }
373
askGroupingOperateOnAll(ApplicationSettings::OperationType type)374 bool ApplicationSettings::askGroupingOperateOnAll(ApplicationSettings::OperationType type)
375 {
376 if (!d->groupingOperateOnAll.contains(type))
377 {
378 throw std::invalid_argument("ApplicationSettings::askGroupingOperateOnAll: Invalid operation type.");
379 }
380
381 if (type == ApplicationSettings::Unspecified)
382 {
383 return false;
384 }
385
386 QPointer<QMessageBox> msgBox = new QMessageBox(qApp->activeWindow());
387 msgBox->setWindowTitle(qApp->applicationName());
388 msgBox->setStandardButtons(QMessageBox::No | QMessageBox::Yes);
389 msgBox->setText(QLatin1String("<p>") + ApplicationSettings::operationTypeTitle(type) +
390 QLatin1String("</p>") + i18n("Do you want to do this operation on all group items?"));
391
392 QCheckBox* const chkBox = new QCheckBox(i18n("Remember choice for this operation"), msgBox);
393 msgBox->setCheckBox(chkBox);
394
395 if (msgBox->exec() == QMessageBox::No)
396 {
397 if (chkBox->isChecked())
398 {
399 setGroupingOperateOnAll(type, ApplicationSettings::No);
400 }
401
402 return false;
403 }
404
405 if (chkBox->isChecked())
406 {
407 setGroupingOperateOnAll(type, ApplicationSettings::Yes);
408 }
409
410 delete msgBox;
411
412 return true;
413 }
414
operationTypeTitle(ApplicationSettings::OperationType type)415 QString ApplicationSettings::operationTypeTitle(ApplicationSettings::OperationType type)
416 {
417 switch (type)
418 {
419 case ApplicationSettings::Metadata:
420 return i18n("Metadata");
421
422 case ApplicationSettings::LightTable:
423 return i18n("Light Table");
424
425 case ApplicationSettings::BQM:
426 return i18n("Batch Queue Manager");
427
428 case ApplicationSettings::Slideshow:
429 return i18n("Slideshow");
430
431 case ApplicationSettings::Rename:
432 return i18n("Renaming");
433
434 case ApplicationSettings::ImportExport:
435 return i18n("Import/Export tools");
436
437 case ApplicationSettings::Tools:
438 return i18n("Tools (editor, panorama, stack blending, calendar, "
439 "external program)");
440 default:
441 throw std::invalid_argument("ApplicationSettings::operationTypeTitle: Invalid operation type.");
442 }
443 }
444
operationTypeExplanation(ApplicationSettings::OperationType type)445 QString ApplicationSettings::operationTypeExplanation(ApplicationSettings::OperationType type)
446 {
447 switch (type)
448 {
449 case ApplicationSettings::Metadata:
450 return i18n("Operations related to metadata, labels, ratings, tags, geolocation and rotation");
451
452 case ApplicationSettings::LightTable:
453 return i18n("Adding items to the Light Table");
454
455 case ApplicationSettings::BQM:
456 return i18n("Adding items to the Batch Queue Manager");
457
458 case ApplicationSettings::Slideshow:
459 return i18n("Opening items in the Slideshow");
460
461 case ApplicationSettings::Rename:
462 return i18n("Renaming items");
463
464 case ApplicationSettings::ImportExport:
465 return i18n("Passing items to import/export tools");
466
467 case ApplicationSettings::Tools:
468 return i18n("Several tools including the editor, panorama, stack blending, "
469 "calendar, html gallery and opening with external programs");
470 default:
471 return QString();
472 }
473 }
474
setApplicationFont(const QFont & font)475 void ApplicationSettings::setApplicationFont(const QFont& font)
476 {
477 if (d->applicationFont != font)
478 {
479 d->applicationFont = font;
480 qApp->setFont(d->applicationFont);
481 qCDebug(DIGIKAM_GENERAL_LOG) << "Switch to application font: " << d->applicationFont;
482 }
483 }
484
getApplicationFont() const485 QFont ApplicationSettings::getApplicationFont() const
486 {
487 return d->applicationFont;
488 }
489
getHelpBoxNotificationSeen()490 bool ApplicationSettings::getHelpBoxNotificationSeen() {
491 KSharedConfigPtr config = KSharedConfig::openConfig();
492 KConfigGroup group = config->group("Notification Messages");
493 bool value = group.readEntry("HelpBoxNotifSeen", false);
494
495 return value;
496 }
497
setHelpBoxNotificationSeen(bool val)498 void ApplicationSettings::setHelpBoxNotificationSeen(bool val) {
499 KSharedConfigPtr config = KSharedConfig::openConfig();
500 KConfigGroup group = config->group("Notification Messages");
501
502 group.writeEntry("HelpBoxNotifSeen", val);
503 config->sync();
504 }
505
506 } // namespace Digikam
507