Debian Codegraph @

src/backend/config/Config.cpp

raw symbols SCIP
1 /*
2 * Copyright (C) 2016 Damir Porobic <https://github.com/damirporobic>
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,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
13 *
14 * You should have received a copy of the GNU General Public License
15 * along with this program; if not, write to the Free Software
16 * Foundation, Inc., 51 Franklin Street, Fifth Floor,
17 * Boston, MA 02110-1301, USA.
18 *
19 */
20
21 #include "Config.h"
22
23 Config::Config(const QSharedPointer<IDirectoryPathProvider> &directoryPathProvider) :
24 mDirectoryPathProvider(directoryPathProvider)
25 {
26
27 }
28
29 // Application
30
31 bool Config::rememberPosition() const
32 {
33 return loadValue(ConfigOptions::rememberPositionString(), true).toBool();
34 }
35
36 void Config::setRememberPosition(bool enabled)
37 {
38 if (rememberPosition() == enabled) {
39 return;
40 }
41 saveValue(ConfigOptions::rememberPositionString(), enabled);
42 }
43
44 bool Config::promptSaveBeforeExit() const
45 {
46 return loadValue(ConfigOptions::promptSaveBeforeExitString(), true).toBool();
47 }
48
49 void Config::setPromptSaveBeforeExit(bool enabled)
50 {
51 if (promptSaveBeforeExit() == enabled) {
52 return;
53 }
54 saveValue(ConfigOptions::promptSaveBeforeExitString(), enabled);
55 }
56
57 bool Config::autoCopyToClipboardNewCaptures() const
58 {
59 return loadValue(ConfigOptions::autoCopyToClipboardNewCapturesString(), false).toBool();
60 }
61
62 void Config::setAutoCopyToClipboardNewCaptures(bool enabled)
63 {
64 if (autoCopyToClipboardNewCaptures() == enabled) {
65 return;
66 }
67 saveValue(ConfigOptions::autoCopyToClipboardNewCapturesString(), enabled);
68 }
69
70 bool Config::autoSaveNewCaptures() const
71 {
72 return loadValue(ConfigOptions::autoSaveNewCapturesString(), false).toBool();
73 }
74
75 void Config::setAutoSaveNewCaptures(bool enabled)
76 {
77 if (autoSaveNewCaptures() == enabled) {
78 return;
79 }
80 saveValue(ConfigOptions::autoSaveNewCapturesString(), enabled);
81 }
82
83 bool Config::autoHideDocks() const
84 {
85 return loadValue(ConfigOptions::autoHideDocksString(), false).toBool();
86 }
87
88 void Config::setAutoHideDocks(bool enabled)
89 {
90 if (autoHideDocks() == enabled) {
91 return;
92 }
93 saveValue(ConfigOptions::autoHideDocksString(), enabled);
94 }
95
96 bool Config::autoResizeToContent() const
97 {
98 return loadValue(ConfigOptions::autoResizeToContentString(), true).toBool();
99 }
100
101 void Config::setAutoResizeToContent(bool enabled)
102 {
103 if (autoResizeToContent() == enabled) {
104 return;
105 }
106 saveValue(ConfigOptions::autoResizeToContentString(), enabled);
107 }
108
109 int Config::resizeToContentDelay() const
110 {
111 return loadValue(ConfigOptions::resizeToContentDelayString(), 10).toInt();
112 }
113
114 void Config::setResizeToContentDelay(int ms)
115 {
116 if (resizeToContentDelay() == ms) {
117 return;
118 }
119 saveValue(ConfigOptions::resizeToContentDelayString(), ms);
120 }
121
122 bool Config::overwriteFile() const
123 {
124 return loadValue(ConfigOptions::overwriteFileEnabledString(), false).toBool();
125 }
126
127 void Config::setOverwriteFile(bool enabled)
128 {
129 if (overwriteFile() == enabled) {
130 return;
131 }
132 saveValue(ConfigOptions::overwriteFileEnabledString(), enabled);
133 }
134
135 bool Config::useTabs() const
136 {
137 return loadValue(ConfigOptions::useTabsString(), true).toBool();
138 }
139
140 void Config::setUseTabs(bool enabled)
141 {
142 if (useTabs() == enabled) {
143 return;
144 }
145 saveValue(ConfigOptions::useTabsString(), enabled);
146 emit annotatorConfigChanged();
147 }
148
149 bool Config::autoHideTabs() const
150 {
151 return loadValue(ConfigOptions::autoHideTabsString(), false).toBool();
152 }
153
154 void Config::setAutoHideTabs(bool enabled)
155 {
156 if (autoHideTabs() == enabled) {
157 return;
158 }
159 saveValue(ConfigOptions::autoHideTabsString(), enabled);
160 emit annotatorConfigChanged();
161 }
162
163 bool Config::captureOnStartup() const
164 {
165 return loadValue(ConfigOptions::captureOnStartupString(), false).toBool();
166 }
167
168 void Config::setCaptureOnStartup(bool enabled)
169 {
170 if (captureOnStartup() == enabled) {
171 return;
172 }
173 saveValue(ConfigOptions::captureOnStartupString(), enabled);
174 }
175
176 QPoint Config::windowPosition() const
177 {
178 // If we are not saving the position we return the default and ignore what
179 // has been save earlier
180 if (!rememberPosition()) {
181 return { 200, 200 };
182 }
183
184 auto defaultPosition = QPoint(200, 200);
185 return loadValue(ConfigOptions::positionString(), defaultPosition).value<QPoint>();
186 }
187
188 void Config::setWindowPosition(const QPoint& position)
189 {
190 if (windowPosition() == position) {
191 return;
192 }
193 saveValue(ConfigOptions::positionString(), position);
194 }
195
196 CaptureModes Config::captureMode() const
197 {
198 // If we are not storing the tool selection, always return the rect area as default
199 if (!rememberToolSelection()) {
200 return CaptureModes::RectArea;
201 }
202
203 return loadValue(ConfigOptions::captureModeString(), (int)CaptureModes::RectArea).value<CaptureModes>();
204 }
205
206 void Config::setCaptureMode(CaptureModes mode)
207 {
208 if (captureMode() == mode) {
209 return;
210 }
211 saveValue(ConfigOptions::captureModeString(), static_cast<int>(mode));
212 }
213
214 QString Config::saveDirectory() const
215 {
216 auto saveDirectoryString = loadValue(ConfigOptions::saveDirectoryString(), mDirectoryPathProvider->home()).toString();
217 if (!saveDirectoryString.isEmpty()) {
218 return saveDirectoryString + QLatin1String("/");
219 } else {
220 return {};
221 }
222 }
223
224 void Config::setSaveDirectory(const QString& path)
225 {
226 if (saveDirectory() == path) {
227 return;
228 }
229 saveValue(ConfigOptions::saveDirectoryString(), path);
230 }
231
232 QString Config::saveFilename() const
233 {
234 auto defaultFilename = QLatin1String("ksnip_$Y$M$D-$T");
235 auto filename = loadValue(ConfigOptions::saveFilenameString(), defaultFilename).toString();
236 if (filename.isEmpty() || filename.isNull()) {
237 filename = defaultFilename;
238 }
239
240 return filename;
241 }
242
243 void Config::setSaveFilename(const QString& filename)
244 {
245 if (saveFilename() == filename) {
246 return;
247 }
248 saveValue(ConfigOptions::saveFilenameString(), filename);
249 }
250
251 QString Config::saveFormat() const
252 {
253 auto defaultFormat = QLatin1String("png");
254 auto format = loadValue(ConfigOptions::saveFormatString(), defaultFormat).toString();
255 if (format.isEmpty() || format.isNull()) {
256 format = defaultFormat;
257 }
258
259 return format;
260 }
261
262 void Config::setSaveFormat(const QString& format)
263 {
264 if (saveFormat() == format) {
265 return;
266 }
267 saveValue(ConfigOptions::saveFormatString(), format);
268 }
269
270 QString Config::applicationStyle() const
271 {
272 auto defaultStyle = QLatin1String("Fusion");
273 return loadValue(ConfigOptions::applicationStyleString(), defaultStyle).toString();
274 }
275
276 void Config::setApplicationStyle(const QString &style)
277 {
278 if (applicationStyle() == style) {
279 return;
280 }
281 saveValue(ConfigOptions::applicationStyleString(), style);
282 }
283
284 TrayIconDefaultActionMode Config::defaultTrayIconActionMode() const
285 {
286 return loadValue(ConfigOptions::trayIconDefaultActionModeString(), (int)TrayIconDefaultActionMode::ShowEditor).value<TrayIconDefaultActionMode>();
287 }
288
289 void Config::setDefaultTrayIconActionMode(TrayIconDefaultActionMode mode)
290 {
291 if (defaultTrayIconActionMode() == mode) {
292 return;
293 }
294 saveValue(ConfigOptions::trayIconDefaultActionModeString(), static_cast<int>(mode));
295 }
296
297 CaptureModes Config::defaultTrayIconCaptureMode() const
298 {
299 return loadValue(ConfigOptions::trayIconDefaultCaptureModeString(), (int)CaptureModes::RectArea).value<CaptureModes>();
300 }
301
302 void Config::setDefaultTrayIconCaptureMode(CaptureModes mode)
303 {
304 if (defaultTrayIconCaptureMode() == mode) {
305 return;
306 }
307 saveValue(ConfigOptions::trayIconDefaultCaptureModeString(), static_cast<int>(mode));
308 }
309
310 bool Config::useTrayIcon() const
311 {
312 return loadValue(ConfigOptions::useTrayIconString(), true).toBool();
313 }
314
315 void Config::setUseTrayIcon(bool enabled)
316 {
317 if (useTrayIcon() == enabled) {
318 return;
319 }
320 saveValue(ConfigOptions::useTrayIconString(), enabled);
321 }
322
323 bool Config::minimizeToTray() const
324 {
325 return loadValue(ConfigOptions::minimizeToTrayString(), true).toBool();
326 }
327
328 void Config::setMinimizeToTray(bool enabled)
329 {
330 if (minimizeToTray() == enabled) {
331 return;
332 }
333 saveValue(ConfigOptions::minimizeToTrayString(), enabled);
334 }
335
336 bool Config::closeToTray() const
337 {
338 return loadValue(ConfigOptions::closeToTrayString(), true).toBool();
339 }
340
341 void Config::setCloseToTray(bool enabled)
342 {
343 if (closeToTray() == enabled) {
344 return;
345 }
346 saveValue(ConfigOptions::closeToTrayString(), enabled);
347 }
348
349 bool Config::trayIconNotificationsEnabled() const
350 {
351 return loadValue(ConfigOptions::trayIconNotificationsEnabledString(), true).toBool();
352 }
353
354 void Config::setTrayIconNotificationsEnabled(bool enabled)
355 {
356 if (trayIconNotificationsEnabled() == enabled) {
357 return;
358 }
359 saveValue(ConfigOptions::trayIconNotificationsEnabledString(), enabled);
360 }
361
362 bool Config::platformSpecificNotificationServiceEnabled() const
363 {
364 return loadValue(ConfigOptions::platformSpecificNotificationServiceEnabledString(), true).toBool();
365 }
366
367 void Config::setPlatformSpecificNotificationServiceEnabled(bool enabled)
368 {
369 if (platformSpecificNotificationServiceEnabled() == enabled) {
370 return;
371 }
372 saveValue(ConfigOptions::platformSpecificNotificationServiceEnabledString(), enabled);
373 }
374
375 bool Config::startMinimizedToTray() const
376 {
377 return loadValue(ConfigOptions::startMinimizedToTrayString(), false).toBool();
378 }
379
380 void Config::setStartMinimizedToTray(bool enabled)
381 {
382 if (startMinimizedToTray() == enabled) {
383 return;
384 }
385 saveValue(ConfigOptions::startMinimizedToTrayString(), enabled);
386 }
387
388 bool Config::rememberLastSaveDirectory() const
389 {
390 return loadValue(ConfigOptions::rememberLastSaveDirectoryString(), false).toBool();
391 }
392
393 void Config::setRememberLastSaveDirectory(bool enabled)
394 {
395 if (rememberLastSaveDirectory() == enabled) {
396 return;
397 }
398 saveValue(ConfigOptions::rememberLastSaveDirectoryString(), enabled);
399 }
400
401 bool Config::useSingleInstance() const
402 {
403 return loadValue(ConfigOptions::useSingleInstanceString(), true).toBool();
404 }
405
406 void Config::setUseSingleInstance(bool enabled)
407 {
408 if (useSingleInstance() == enabled) {
409 return;
410 }
411 saveValue(ConfigOptions::useSingleInstanceString(), enabled);
412 }
413
414 bool Config::hideMainWindowDuringScreenshot() const
415 {
416 return loadValue(ConfigOptions::hideMainWindowDuringScreenshotString(), true).toBool();
417 }
418
419 void Config::setHideMainWindowDuringScreenshot(bool enabled)
420 {
421 if (hideMainWindowDuringScreenshot() == enabled) {
422 return;
423 }
424 saveValue(ConfigOptions::hideMainWindowDuringScreenshotString(), enabled);
425 }
426
427 bool Config::allowResizingRectSelection() const
428 {
429 return loadValue(ConfigOptions::allowResizingRectSelectionString(), false).toBool();
430 }
431
432 void Config::setAllowResizingRectSelection(bool enabled)
433 {
434 if (allowResizingRectSelection() == enabled) {
435 return;
436 }
437 saveValue(ConfigOptions::allowResizingRectSelectionString(), enabled);
438 }
439
440 bool Config::showSnippingAreaInfoText() const
441 {
442 return loadValue(ConfigOptions::showSnippingAreaInfoTextString(), true).toBool();
443 }
444
445 void Config::setShowSnippingAreaInfoText(bool enabled)
446 {
447 if (showSnippingAreaInfoText() == enabled) {
448 return;
449 }
450 saveValue(ConfigOptions::showSnippingAreaInfoTextString(), enabled);
451 }
452
453 bool Config::snippingAreaOffsetEnable() const
454 {
455 return loadValue(ConfigOptions::snippingAreaOffsetEnableString(), false).toBool();
456 }
457
458 void Config::setSnippingAreaOffsetEnable(bool enabled)
459 {
460 if (snippingAreaOffsetEnable() == enabled) {
461 return;
462 }
463 saveValue(ConfigOptions::snippingAreaOffsetEnableString(), enabled);
464
465 emit snippingAreaChangedChanged();
466 }
467
468 QPointF Config::snippingAreaOffset() const
469 {
470 return loadValue(ConfigOptions::snippingAreaOffsetString(), QPointF(0, 0)).value<QPointF>();
471 }
472
473 void Config::setSnippingAreaOffset(const QPointF &offset)
474 {
475 if (snippingAreaOffset() == offset) {
476 return;
477 }
478 saveValue(ConfigOptions::snippingAreaOffsetString(), offset);
479
480 emit snippingAreaChangedChanged();
481 }
482
483 int Config::implicitCaptureDelay() const
484 {
485 return loadValue(ConfigOptions::implicitCaptureDelayString(), 200).value<int>();
486 }
487
488 void Config::setImplicitCaptureDelay(int delay)
489 {
490 if (implicitCaptureDelay() == delay) {
491 return;
492 }
493 saveValue(ConfigOptions::implicitCaptureDelayString(), delay);
494
495 emit delayChanged();
496 }
497
498 SaveQualityMode Config::saveQualityMode() const
499 {
500 return loadValue(ConfigOptions::saveQualityModeString(), (int)SaveQualityMode::Default).value<SaveQualityMode>();
501 }
502
503 void Config::setSaveQualityMode(SaveQualityMode mode)
504 {
505 if (saveQualityMode() == mode) {
506 return;
507 }
508
509 saveValue(ConfigOptions::saveQualityModeString(), static_cast<int>(mode));
510 }
511
512 int Config::saveQualityFactor() const
513 {
514 return loadValue(ConfigOptions::saveQualityFactorString(), 50).toInt();
515 }
516
517 void Config::setSaveQualityFactor(int factor)
518 {
519 if (saveQualityFactor() == factor) {
520 return;
521 }
522
523 saveValue(ConfigOptions::saveQualityFactorString(), factor);
524 }
525
526 bool Config::isDebugEnabled() const
527 {
528 return loadValue(ConfigOptions::isDebugEnabledString(), false).toBool();
529 }
530
531 void Config::setIsDebugEnabled(bool enabled)
532 {
533 if (isDebugEnabled() == enabled) {
534 return;
535 }
536
537 saveValue(ConfigOptions::isDebugEnabledString(), enabled);
538 }
539
540 QString Config::tempDirectory() const
541 {
542 return loadValue(ConfigOptions::tempDirectoryString(), QDir::tempPath()).toString();
543 }
544
545 void Config::setTempDirectory(const QString& path)
546 {
547 if (tempDirectory() == path) {
548 return;
549 }
550 saveValue(ConfigOptions::tempDirectoryString(), path);
551 }
552
553 // Annotator
554
555 bool Config::rememberToolSelection() const
556 {
557 return loadValue(ConfigOptions::rememberToolSelectionString(), true).toBool();
558 }
559
560 void Config::setRememberToolSelection(bool enabled)
561 {
562 if (rememberToolSelection() == enabled) {
563 return;
564 }
565 saveValue(ConfigOptions::rememberToolSelectionString(), enabled);
566 }
567
568 bool Config::switchToSelectToolAfterDrawingItem() const
569 {
570 return loadValue(ConfigOptions::switchToSelectToolAfterDrawingItemString(), false).toBool();
571 }
572
573 void Config::setSwitchToSelectToolAfterDrawingItem(bool enabled)
574 {
575 if (switchToSelectToolAfterDrawingItem() == enabled) {
576 return;
577 }
578 saveValue(ConfigOptions::switchToSelectToolAfterDrawingItemString(), enabled);
579 emit annotatorConfigChanged();
580 }
581
582 bool Config::selectItemAfterDrawing() const
583 {
584 return loadValue(ConfigOptions::selectItemAfterDrawingString(), true).toBool();
585 }
586
587 void Config::setSelectItemAfterDrawing(bool enabled)
588 {
589 if (selectItemAfterDrawing() == enabled) {
590 return;
591 }
592 saveValue(ConfigOptions::selectItemAfterDrawingString(), enabled);
593 emit annotatorConfigChanged();
594 }
595
596 bool Config::numberToolSeedChangeUpdatesAllItems() const
597 {
598 return loadValue(ConfigOptions::numberToolSeedChangeUpdatesAllItemsString(), true).toBool();
599 }
600
601 void Config::setNumberToolSeedChangeUpdatesAllItems(bool enabled)
602 {
603 if (numberToolSeedChangeUpdatesAllItems() == enabled) {
604 return;
605 }
606 saveValue(ConfigOptions::numberToolSeedChangeUpdatesAllItemsString(), enabled);
607 emit annotatorConfigChanged();
608 }
609
610 bool Config::smoothPathEnabled() const
611 {
612 return loadValue(ConfigOptions::smoothPathEnabledString(), true).toBool();
613 }
614
615 void Config::setSmoothPathEnabled(bool enabled)
616 {
617 if (smoothPathEnabled() == enabled) {
618 return;
619 }
620
621 saveValue(ConfigOptions::smoothPathEnabledString(), enabled);
622 emit annotatorConfigChanged();
623 }
624
625 int Config::smoothFactor() const
626 {
627 return loadValue(ConfigOptions::smoothPathFactorString(), 7).toInt();
628 }
629
630 void Config::setSmoothFactor(int factor)
631 {
632 if (smoothFactor() == factor) {
633 return;
634 }
635
636 saveValue(ConfigOptions::smoothPathFactorString(), factor);
637 emit annotatorConfigChanged();
638 }
639
640 bool Config::rotateWatermarkEnabled() const
641 {
642 return loadValue(ConfigOptions::rotateWatermarkEnabledString(), true).toBool();
643 }
644
645 void Config::setRotateWatermarkEnabled(bool enabled)
646 {
647 if (rotateWatermarkEnabled() == enabled) {
648 return;
649 }
650
651 saveValue(ConfigOptions::rotateWatermarkEnabledString(), enabled);
652 }
653
654 QStringList Config::stickerPaths() const
655 {
656 return loadValue(ConfigOptions::stickerPathsString(), QVariant::fromValue(QStringList())).value<QStringList>();
657 }
658
659 void Config::setStickerPaths(const QStringList &paths)
660 {
661 if (stickerPaths() == paths) {
662 return;
663 }
664
665 saveValue(ConfigOptions::stickerPathsString(), QVariant::fromValue(paths));
666 emit annotatorConfigChanged();
667 }
668
669 bool Config::useDefaultSticker() const
670 {
671 return loadValue(ConfigOptions::useDefaultStickerString(), true).toBool();
672 }
673
674 void Config::setUseDefaultSticker(bool enabled)
675 {
676 if (useDefaultSticker() == enabled) {
677 return;
678 }
679
680 saveValue(ConfigOptions::useDefaultStickerString(), enabled);
681 emit annotatorConfigChanged();
682 }
683
684 QColor Config::canvasColor() const
685 {
686 return loadValue(ConfigOptions::canvasColorString(), QColor(Qt::white)).value<QColor>();
687 }
688
689 void Config::setCanvasColor(const QColor &color)
690 {
691 if (canvasColor() == color) {
692 return;
693 }
694
695 saveValue(ConfigOptions::canvasColorString(), color);
696 emit annotatorConfigChanged();
697 }
698
699 bool Config::isControlsWidgetVisible() const
700 {
701 return loadValue(ConfigOptions::isControlsWidgetVisibleString(), false).toBool();
702 }
703
704 void Config::setIsControlsWidgetVisible(bool isVisible)
705 {
706 if (isControlsWidgetVisible() == isVisible) {
707 return;
708 }
709
710 saveValue(ConfigOptions::isControlsWidgetVisibleString(), isVisible);
711 emit annotatorConfigChanged();
712 }
713
714 // Image Grabber
715
716 bool Config::isFreezeImageWhileSnippingEnabledReadOnly() const
717 {
718 return false;
719 }
720
721 bool Config::freezeImageWhileSnippingEnabled() const
722 {
723 return loadValue(ConfigOptions::freezeImageWhileSnippingEnabledString(), true).toBool();
724 }
725
726 void Config::setFreezeImageWhileSnippingEnabled(bool enabled)
727 {
728 if (freezeImageWhileSnippingEnabled() == enabled) {
729 return;
730 }
731 saveValue(ConfigOptions::freezeImageWhileSnippingEnabledString(), enabled);
732 }
733
734 bool Config::captureCursor() const
735 {
736 return loadValue(ConfigOptions::captureCursorString(), true).toBool();
737 }
738
739 void Config::setCaptureCursor(bool enabled)
740 {
741 if (captureCursor() == enabled) {
742 return;
743 }
744 saveValue(ConfigOptions::captureCursorString(), enabled);
745 }
746
747 bool Config::snippingAreaRulersEnabled() const
748 {
749 return loadValue(ConfigOptions::snippingAreaRulersEnabledString(), true).toBool();
750 }
751
752 void Config::setSnippingAreaRulersEnabled(bool enabled)
753 {
754 if (snippingAreaRulersEnabled() == enabled) {
755 return;
756 }
757 saveValue(ConfigOptions::snippingAreaRulersEnabledString(), enabled);
758 }
759
760 bool Config::snippingAreaPositionAndSizeInfoEnabled() const
761 {
762 return loadValue(ConfigOptions::snippingAreaPositionAndSizeInfoEnabledString(), true).toBool();
763 }
764
765 void Config::setSnippingAreaPositionAndSizeInfoEnabled(bool enabled)
766 {
767 if (snippingAreaPositionAndSizeInfoEnabled() == enabled) {
768 return;
769 }
770 saveValue(ConfigOptions::snippingAreaPositionAndSizeInfoEnabledString(), enabled);
771 }
772
773 bool Config::showMainWindowAfterTakingScreenshotEnabled() const
774 {
775 return loadValue(ConfigOptions::showMainWindowAfterTakingScreenshotEnabledString(), true).toBool();
776 }
777
778 void Config::setShowMainWindowAfterTakingScreenshotEnabled(bool enabled)
779 {
780 if (showMainWindowAfterTakingScreenshotEnabled() == enabled) {
781 return;
782 }
783 saveValue(ConfigOptions::showMainWindowAfterTakingScreenshotEnabledString(), enabled);
784 }
785
786 bool Config::isSnippingAreaMagnifyingGlassEnabledReadOnly() const
787 {
788 return false;
789 }
790
791 bool Config::snippingAreaMagnifyingGlassEnabled() const
792 {
793 return loadValue(ConfigOptions::snippingAreaMagnifyingGlassEnabledString(), true).toBool();
794 }
795
796 void Config::setSnippingAreaMagnifyingGlassEnabled(bool enabled)
797 {
798 if (snippingAreaMagnifyingGlassEnabled() == enabled) {
799 return;
800 }
801 saveValue(ConfigOptions::snippingAreaMagnifyingGlassEnabledString(), enabled);
802 }
803
804 int Config::captureDelay() const
805 {
806 return loadValue(ConfigOptions::captureDelayString(), 0).toInt();
807 }
808
809 void Config::setCaptureDelay(int delay)
810 {
811 if (captureDelay() == delay) {
812 return;
813 }
814 saveValue(ConfigOptions::captureDelayString(), delay);
815 }
816
817 int Config::snippingCursorSize() const
818 {
819 return loadValue(ConfigOptions::snippingCursorSizeString(), 1).toInt();
820 }
821
822 void Config::setSnippingCursorSize(int size)
823 {
824 if (snippingCursorSize() == size) {
825 return;
826 }
827 saveValue(ConfigOptions::snippingCursorSizeString(), size);
828 }
829
830 QColor Config::snippingCursorColor() const
831 {
832 auto defaultColor = QColor(27, 20, 77);
833 return loadValue(ConfigOptions::snippingCursorColorString(), defaultColor).value<QColor>();
834 }
835
836 void Config::setSnippingCursorColor(const QColor& color)
837 {
838 if (snippingCursorColor() == color) {
839 return;
840 }
841 saveValue(ConfigOptions::snippingCursorColorString(), color);
842 }
843
844 QColor Config::snippingAdornerColor() const
845 {
846 return loadValue(ConfigOptions::snippingAdornerColorString(), QColor(Qt::red)).value<QColor>();
847 }
848
849 void Config::setSnippingAdornerColor(const QColor& color)
850 {
851 if (snippingAdornerColor() == color) {
852 return;
853 }
854 saveValue(ConfigOptions::snippingAdornerColorString(), color);
855 }
856
857 int Config::snippingAreaTransparency() const
858 {
859 return loadValue(ConfigOptions::snippingAreaTransparencyString(), 150).value<int>();
860 }
861
862 void Config::setSnippingAreaTransparency(int transparency)
863 {
864 if (snippingAreaTransparency() == transparency) {
865 return;
866 }
867 saveValue(ConfigOptions::snippingAreaTransparencyString(), transparency);
868 }
869
870 QRect Config::lastRectArea() const
871 {
872 return loadValue(ConfigOptions::lastRectAreaString(), QRect()).value<QRect>();
873 }
874
875 void Config::setLastRectArea(const QRect &rectArea)
876 {
877 if (lastRectArea() == rectArea) {
878 return;
879 }
880 saveValue(ConfigOptions::lastRectAreaString(), rectArea);
881 }
882
883 bool Config::isForceGenericWaylandEnabledReadOnly() const
884 {
885 return true;
886 }
887
888 bool Config::forceGenericWaylandEnabled() const
889 {
890 return loadValue(ConfigOptions::forceGenericWaylandEnabledString(), false).toBool();
891 }
892
893 void Config::setForceGenericWaylandEnabled(bool enabled)
894 {
895 if (forceGenericWaylandEnabled() == enabled) {
896 return;
897 }
898 saveValue(ConfigOptions::forceGenericWaylandEnabledString(), enabled);
899 }
900
901 bool Config::isScaleGenericWaylandScreenshotEnabledReadOnly() const
902 {
903 return true;
904 }
905
906 bool Config::scaleGenericWaylandScreenshotsEnabled() const
907 {
908 return loadValue(ConfigOptions::scaleWaylandScreenshotsEnabledString(), false).toBool();
909 }
910
911 void Config::setScaleGenericWaylandScreenshots(bool enabled)
912 {
913 if (scaleGenericWaylandScreenshotsEnabled() == enabled) {
914 return;
915 }
916 saveValue(ConfigOptions::scaleWaylandScreenshotsEnabledString(), enabled);
917 }
918
919 // Uploader
920
921 bool Config::confirmBeforeUpload() const
922 {
923 return loadValue(ConfigOptions::confirmBeforeUploadString(), true).toBool();
924 }
925
926 void Config::setConfirmBeforeUpload(bool enabled)
927 {
928 if (confirmBeforeUpload() == enabled) {
929 return;
930 }
931 saveValue(ConfigOptions::confirmBeforeUploadString(), enabled);
932 }
933
934 UploaderType Config::uploaderType() const
935 {
936 return loadValue(ConfigOptions::uploaderTypeString(), static_cast<int>(UploaderType::Imgur)).value<UploaderType >();
937 }
938
939 void Config::setUploaderType(UploaderType type)
940 {
941 if (uploaderType() == type) {
942 return;
943 }
944 saveValue(ConfigOptions::uploaderTypeString(), static_cast<int>(type));
945 }
946
947 // Imgur Uploader
948
949 QString Config::imgurUsername() const
950 {
951 auto defaultUsername = QLatin1String("");
952 return loadValue(ConfigOptions::imgurUsernameString(), defaultUsername).toString();
953 }
954
955 void Config::setImgurUsername(const QString& username)
956 {
957 if (imgurUsername() == username) {
958 return;
959 }
960 saveValue(ConfigOptions::imgurUsernameString(), username);
961 }
962
963 QByteArray Config::imgurClientId() const
964 {
965 auto defaultClientId = QLatin1String("");
966 return loadValue(ConfigOptions::imgurClientIdString(), defaultClientId).toByteArray();
967 }
968
969 void Config::setImgurClientId(const QString& clientId)
970 {
971 if (imgurClientId() == clientId) {
972 return;
973 }
974 saveValue(ConfigOptions::imgurClientIdString(), clientId);
975 }
976
977 QByteArray Config::imgurClientSecret() const
978 {
979 auto defaultClientSecret = QLatin1String("");
980 return loadValue(ConfigOptions::imgurClientSecretString(), defaultClientSecret).toByteArray();
981 }
982
983 void Config::setImgurClientSecret(const QString& clientSecret)
984 {
985 if (imgurClientSecret() == clientSecret) {
986 return;
987 }
988 saveValue(ConfigOptions::imgurClientSecretString(), clientSecret);
989 }
990
991 QByteArray Config::imgurAccessToken() const
992 {
993 auto defaultAccessToken = QLatin1String("");
994 return loadValue(ConfigOptions::imgurAccessTokenString(), defaultAccessToken).toByteArray();
995 }
996
997 void Config::setImgurAccessToken(const QString& accessToken)
998 {
999 if (imgurAccessToken() == accessToken) {
1000 return;
1001 }
1002 saveValue(ConfigOptions::imgurAccessTokenString(), accessToken);
1003 }
1004
1005 QByteArray Config::imgurRefreshToken() const
1006 {
1007 auto defaultRefreshToken = QLatin1String("");
1008 return loadValue(ConfigOptions::imgurRefreshTokenString(), defaultRefreshToken).toByteArray();
1009 }
1010
1011 void Config::setImgurRefreshToken(const QString& refreshToken)
1012 {
1013 if (imgurRefreshToken() == refreshToken) {
1014 return;
1015 }
1016 saveValue(ConfigOptions::imgurRefreshTokenString(), refreshToken);
1017 }
1018
1019 bool Config::imgurForceAnonymous() const
1020 {
1021 return loadValue(ConfigOptions::imgurForceAnonymousString(), false).toBool();
1022 }
1023
1024 void Config::setImgurForceAnonymous(bool enabled)
1025 {
1026 if (imgurForceAnonymous() == enabled) {
1027 return;
1028 }
1029 saveValue(ConfigOptions::imgurForceAnonymousString(), enabled);
1030 }
1031
1032 bool Config::imgurLinkDirectlyToImage() const
1033 {
1034 return loadValue(ConfigOptions::imgurLinkDirectlyToImageString(), false).toBool();
1035 }
1036
1037 void Config::setImgurLinkDirectlyToImage(bool enabled)
1038 {
1039 if (imgurLinkDirectlyToImage() == enabled) {
1040 return;
1041 }
1042 saveValue(ConfigOptions::imgurLinkDirectlyToImageString(), enabled);
1043 }
1044
1045 bool Config::imgurAlwaysCopyToClipboard() const
1046 {
1047 return loadValue(ConfigOptions::imgurAlwaysCopyToClipboardString(), false).toBool();
1048 }
1049
1050 void Config::setImgurAlwaysCopyToClipboard(bool enabled)
1051 {
1052 if (imgurAlwaysCopyToClipboard() == enabled) {
1053 return;
1054 }
1055 saveValue(ConfigOptions::imgurAlwaysCopyToClipboardString(), enabled);
1056 }
1057
1058 bool Config::imgurOpenLinkInBrowser() const
1059 {
1060 return loadValue(ConfigOptions::imgurOpenLinkInBrowserString(), true).toBool();
1061 }
1062
1063 void Config::setImgurOpenLinkInBrowser(bool enabled)
1064 {
1065 if (imgurOpenLinkInBrowser() == enabled) {
1066 return;
1067 }
1068 saveValue(ConfigOptions::imgurOpenLinkInBrowserString(), enabled);
1069 }
1070
1071 QString Config::imgurUploadTitle() const
1072 {
1073 return loadValue(ConfigOptions::imgurUploadTitleString(), DefaultValues::ImgurUploadTitle).toString();
1074 }
1075
1076 void Config::setImgurUploadTitle(const QString &uploadTitle)
1077 {
1078 if (imgurUploadTitle() == uploadTitle) {
1079 return;
1080 }
1081 saveValue(ConfigOptions::imgurUploadTitleString(), uploadTitle);
1082 }
1083
1084 QString Config::imgurUploadDescription() const
1085 {
1086 return loadValue(ConfigOptions::imgurUploadDescriptionString(), DefaultValues::ImgurUploadDescription).toString();
1087 }
1088
1089 void Config::setImgurUploadDescription(const QString &uploadDescription)
1090 {
1091 if (imgurUploadDescription() == uploadDescription) {
1092 return;
1093 }
1094 saveValue(ConfigOptions::imgurUploadDescriptionString(), uploadDescription);
1095 }
1096
1097 QString Config::imgurBaseUrl() const
1098 {
1099 return loadValue(ConfigOptions::imgurBaseUrlString(), DefaultValues::ImgurBaseUrl).toString();
1100 }
1101
1102 void Config::setImgurBaseUrl(const QString &baseUrl)
1103 {
1104 if (imgurBaseUrl() == baseUrl) {
1105 return;
1106 }
1107 saveValue(ConfigOptions::imgurBaseUrlString(), baseUrl);
1108 }
1109
1110 // Script Uploader
1111
1112 QString Config::uploadScriptPath() const
1113 {
1114 return loadValue(ConfigOptions::uploadScriptPathString(), QString()).toString();
1115 }
1116
1117 void Config::setUploadScriptPath(const QString &path)
1118 {
1119 if (uploadScriptPath() == path) {
1120 return;
1121 }
1122 saveValue(ConfigOptions::uploadScriptPathString(), path);
1123 }
1124
1125 bool Config::uploadScriptCopyOutputToClipboard() const
1126 {
1127 return loadValue(ConfigOptions::uploadScriptCopyOutputToClipboardString(), false).toBool();
1128 }
1129
1130 void Config::setUploadScriptCopyOutputToClipboard(bool enabled)
1131 {
1132 if (uploadScriptCopyOutputToClipboard() == enabled) {
1133 return;
1134 }
1135 saveValue(ConfigOptions::uploadScriptCopyOutputToClipboardString(), enabled);
1136 }
1137
1138 QString Config::uploadScriptCopyOutputFilter() const
1139 {
1140 return loadValue(ConfigOptions::uploadScriptCopyOutputFilterString(), QString()).toString();
1141 }
1142
1143 void Config::setUploadScriptCopyOutputFilter(const QString &regex)
1144 {
1145 if (uploadScriptCopyOutputFilter() == regex) {
1146 return;
1147 }
1148 saveValue(ConfigOptions::uploadScriptCopyOutputFilterString(), regex);
1149 }
1150
1151 bool Config::uploadScriptStopOnStdErr() const
1152 {
1153 return loadValue(ConfigOptions::uploadScriptStopOnStdErrString(), true).toBool();
1154 }
1155
1156 void Config::setUploadScriptStopOnStdErr(bool enabled)
1157 {
1158 if (uploadScriptStopOnStdErr() == enabled) {
1159 return;
1160 }
1161 saveValue(ConfigOptions::uploadScriptStopOnStdErrString(), enabled);
1162 }
1163
1164 // FTP Uploader
1165
1166 bool Config::ftpUploadForceAnonymous() const
1167 {
1168 return loadValue(ConfigOptions::ftpUploadForceAnonymousString(), false).toBool();
1169 }
1170
1171 void Config::setFtpUploadForceAnonymous(bool enabled)
1172 {
1173 if (ftpUploadForceAnonymous() == enabled) {
1174 return;
1175 }
1176 saveValue(ConfigOptions::ftpUploadForceAnonymousString(), enabled);
1177 }
1178
1179 QString Config::ftpUploadUrl() const
1180 {
1181 return loadValue(ConfigOptions::ftpUploadUrlString(), QString()).toString();
1182 }
1183
1184 void Config::setFtpUploadUrl(const QString &path)
1185 {
1186 if (ftpUploadUrl() == path) {
1187 return;
1188 }
1189 saveValue(ConfigOptions::ftpUploadUrlString(), path);
1190 }
1191
1192 QString Config::ftpUploadUsername() const
1193 {
1194 return loadValue(ConfigOptions::ftpUploadUsernameString(), QString()).toString();
1195 }
1196
1197 void Config::setFtpUploadUsername(const QString &username)
1198 {
1199 if (ftpUploadUsername() == username) {
1200 return;
1201 }
1202 saveValue(ConfigOptions::ftpUploadUsernameString(), username);
1203 }
1204
1205 QString Config::ftpUploadPassword() const
1206 {
1207 return loadValue(ConfigOptions::ftpUploadPasswordString(), QString()).toString();
1208 }
1209
1210 void Config::setFtpUploadPassword(const QString &password)
1211 {
1212 if (ftpUploadPassword() == password) {
1213 return;
1214 }
1215 saveValue(ConfigOptions::ftpUploadPasswordString(), password);
1216 }
1217
1218 // HotKeys
1219
1220 bool Config::isGlobalHotKeysEnabledReadOnly() const
1221 {
1222 return false;
1223 }
1224
1225 bool Config::globalHotKeysEnabled() const
1226 {
1227 return loadValue(ConfigOptions::globalHotKeysEnabledString(), true).toBool();
1228 }
1229
1230 void Config::setGlobalHotKeysEnabled(bool enabled)
1231 {
1232 if (globalHotKeysEnabled() == enabled) {
1233 return;
1234 }
1235 saveValue(ConfigOptions::globalHotKeysEnabledString(), enabled);
1236 emit hotKeysChanged();
1237 }
1238
1239 QKeySequence Config::rectAreaHotKey() const
1240 {
1241 return loadValue(ConfigOptions::rectAreaHotKeyString(), QKeySequence(Qt::ALT | Qt::SHIFT | Qt::Key_R)).value<QKeySequence>();
1242 }
1243
1244 void Config::setRectAreaHotKey(const QKeySequence &keySequence)
1245 {
1246 if (rectAreaHotKey() == keySequence) {
1247 return;
1248 }
1249 saveValue(ConfigOptions::rectAreaHotKeyString(), keySequence);
1250 emit hotKeysChanged();
1251 }
1252
1253
1254 QKeySequence Config::lastRectAreaHotKey() const
1255 {
1256 return loadValue(ConfigOptions::lastRectAreaHotKeyString(), QKeySequence(Qt::ALT | Qt::SHIFT | Qt::Key_L)).value<QKeySequence>();
1257 }
1258
1259 void Config::setLastRectAreaHotKey(const QKeySequence &keySequence)
1260 {
1261 if (lastRectAreaHotKey() == keySequence) {
1262 return;
1263 }
1264 saveValue(ConfigOptions::lastRectAreaHotKeyString(), keySequence);
1265 emit hotKeysChanged();
1266 }
1267
1268 QKeySequence Config::fullScreenHotKey() const
1269 {
1270 return loadValue(ConfigOptions::fullScreenHotKeyString(), QKeySequence(Qt::ALT | Qt::SHIFT | Qt::Key_F)).value<QKeySequence>();
1271 }
1272
1273 void Config::setFullScreenHotKey(const QKeySequence &keySequence)
1274 {
1275 if (fullScreenHotKey() == keySequence) {
1276 return;
1277 }
1278 saveValue(ConfigOptions::fullScreenHotKeyString(), keySequence);
1279 emit hotKeysChanged();
1280 }
1281
1282 QKeySequence Config::currentScreenHotKey() const
1283 {
1284 return loadValue(ConfigOptions::currentScreenHotKeyString(), QKeySequence(Qt::ALT | Qt::SHIFT | Qt::Key_C)).value<QKeySequence>();
1285 }
1286
1287 void Config::setCurrentScreenHotKey(const QKeySequence &keySequence)
1288 {
1289 if (currentScreenHotKey() == keySequence) {
1290 return;
1291 }
1292 saveValue(ConfigOptions::currentScreenHotKeyString(), keySequence);
1293 emit hotKeysChanged();
1294 }
1295
1296 QKeySequence Config::activeWindowHotKey() const
1297 {
1298 return loadValue(ConfigOptions::activeWindowHotKeyString(), QKeySequence(Qt::ALT | Qt::SHIFT | Qt::Key_A)).value<QKeySequence>();
1299 }
1300
1301 void Config::setActiveWindowHotKey(const QKeySequence &keySequence)
1302 {
1303 if (activeWindowHotKey() == keySequence) {
1304 return;
1305 }
1306 saveValue(ConfigOptions::activeWindowHotKeyString(), keySequence);
1307 emit hotKeysChanged();
1308 }
1309
1310 QKeySequence Config::windowUnderCursorHotKey() const
1311 {
1312 return loadValue(ConfigOptions::windowUnderCursorHotKeyString(), QKeySequence(Qt::ALT | Qt::SHIFT | Qt::Key_U)).value<QKeySequence>();
1313 }
1314
1315 void Config::setWindowUnderCursorHotKey(const QKeySequence &keySequence)
1316 {
1317 if (windowUnderCursorHotKey() == keySequence) {
1318 return;
1319 }
1320 saveValue(ConfigOptions::windowUnderCursorHotKeyString(), keySequence);
1321 emit hotKeysChanged();
1322 }
1323
1324 QKeySequence Config::portalHotKey() const
1325 {
1326 return loadValue(ConfigOptions::portalHotKeyString(), QKeySequence(Qt::ALT | Qt::SHIFT | Qt::Key_T)).value<QKeySequence>();
1327 }
1328
1329 void Config::setPortalHotKey(const QKeySequence &keySequence)
1330 {
1331 if (portalHotKey() == keySequence) {
1332 return;
1333 }
1334 saveValue(ConfigOptions::portalHotKeyString(), keySequence);
1335 emit hotKeysChanged();
1336 }
1337
1338 // Actions
1339
1340 QList<Action> Config::actions()
1341 {
1342 QList<Action> actions;
1343 auto count = mConfig.beginReadArray(ConfigOptions::actionsString());
1344 for (auto index = 0; index < count; index++) {
1345 mConfig.setArrayIndex(index);
1346 Action action;
1347 action.setName(mConfig.value(ConfigOptions::actionNameString()).toString());
1348 action.setShortcut(mConfig.value(ConfigOptions::actionShortcutString()).value<QKeySequence>());
1349 action.setIsGlobalShortcut(mConfig.value(ConfigOptions::actionShortcutIsGlobalString(), true).value<bool>());
1350 action.setIsCaptureEnabled(mConfig.value(ConfigOptions::actionIsCaptureEnabledString()).toBool());
1351 action.setIncludeCursor(mConfig.value(ConfigOptions::actionIncludeCursorString()).toBool());
1352 action.setCaptureDelay(mConfig.value(ConfigOptions::actionCaptureDelayString()).toInt());
1353 action.setCaptureMode(mConfig.value(ConfigOptions::actionCaptureModeString()).value<CaptureModes>());
1354 action.setIsPinImageEnabled(mConfig.value(ConfigOptions::actionIsPinImageEnabledString()).toBool());
1355 action.setIsUploadEnabled(mConfig.value(ConfigOptions::actionIsUploadEnabledString()).toBool());
1356 action.setIsOpenDirectoryEnabled(mConfig.value(ConfigOptions::actionIsOpenDirectoryEnabledString()).toBool());
1357 action.setIsCopyToClipboardEnabled(mConfig.value(ConfigOptions::actionIsCopyToClipboardEnabledString()).toBool());
1358 action.setIsSaveEnabled(mConfig.value(ConfigOptions::actionIsSaveEnabledString()).toBool());
1359 action.setIsHideMainWindowEnabled(mConfig.value(ConfigOptions::actionIsHideMainWindowEnabledString()).toBool());
1360 actions.append(action);
1361 }
1362 mConfig.endArray();
1363 return actions;
1364 }
1365
1366 void Config::setActions(const QList<Action> &actions)
1367 {
1368 auto savedActions = this->actions();
1369
1370 if(savedActions == actions) {
1371 return;
1372 }
1373
1374 mConfig.remove(ConfigOptions::actionsString());
1375
1376 auto count = actions.count();
1377 mConfig.beginWriteArray(ConfigOptions::actionsString());
1378 for (auto index = 0; index < count; ++index) {
1379 const auto& action = actions.at(index);
1380 mConfig.setArrayIndex(index);
1381 mConfig.setValue(ConfigOptions::actionNameString(), action.name());
1382 mConfig.setValue(ConfigOptions::actionShortcutString(), action.shortcut());
1383 mConfig.setValue(ConfigOptions::actionShortcutIsGlobalString(), action.isGlobalShortcut());
1384 mConfig.setValue(ConfigOptions::actionIsCaptureEnabledString(), action.isCaptureEnabled());
1385 mConfig.setValue(ConfigOptions::actionIncludeCursorString(), action.includeCursor());
1386 mConfig.setValue(ConfigOptions::actionCaptureDelayString(), action.captureDelay());
1387 mConfig.setValue(ConfigOptions::actionCaptureModeString(), static_cast<int>(action.captureMode()));
1388 mConfig.setValue(ConfigOptions::actionIsPinImageEnabledString(), action.isPinImageEnabled());
1389 mConfig.setValue(ConfigOptions::actionIsUploadEnabledString(), action.isUploadEnabled());
1390 mConfig.setValue(ConfigOptions::actionIsOpenDirectoryEnabledString(), action.isOpenDirectoryEnabled());
1391 mConfig.setValue(ConfigOptions::actionIsCopyToClipboardEnabledString(), action.isCopyToClipboardEnabled());
1392 mConfig.setValue(ConfigOptions::actionIsSaveEnabledString(), action.isSaveEnabled());
1393 mConfig.setValue(ConfigOptions::actionIsHideMainWindowEnabledString(), action.isHideMainWindowEnabled());
1394 }
1395 mConfig.endArray();
1396
1397 emit actionsChanged();
1398 emit hotKeysChanged();
1399 }
1400
1401 QString Config::pluginPath() const
1402 {
1403 return loadValue(ConfigOptions::pluginPathString()).toString();
1404 }
1405
1406 void Config::setPluginPath(const QString &path)
1407 {
1408 if (pluginPath() == path) {
1409 return;
1410 }
1411 saveValue(ConfigOptions::pluginPathString(), path);
1412 }
1413
1414 QList<PluginInfo> Config::pluginInfos()
1415 {
1416 QList<PluginInfo> pluginInfos;
1417 auto count = mConfig.beginReadArray(ConfigOptions::pluginInfosString());
1418 for (auto index = 0; index < count; index++) {
1419 mConfig.setArrayIndex(index);
1420 auto path = mConfig.value(ConfigOptions::pluginInfoPathString()).toString();
1421 auto type = mConfig.value(ConfigOptions::pluginInfoTypeString()).value<PluginType>();
1422 auto version = mConfig.value(ConfigOptions::pluginInfoVersionString()).toString();
1423 PluginInfo pluginInfo(type, version, path);
1424 pluginInfos.append(pluginInfo);
1425 }
1426 mConfig.endArray();
1427 return pluginInfos;
1428 }
1429
1430 void Config::setPluginInfos(const QList<PluginInfo> &pluginInfos)
1431 {
1432 auto savedPluginInfos = this->pluginInfos();
1433 if(savedPluginInfos == pluginInfos) {
1434 return;
1435 }
1436
1437 mConfig.remove(ConfigOptions::pluginInfosString());
1438
1439 auto count = pluginInfos.count();
1440 mConfig.beginWriteArray(ConfigOptions::pluginInfosString());
1441 for (auto index = 0; index < count; ++index) {
1442 const auto& pluginInfo = pluginInfos.at(index);
1443 mConfig.setArrayIndex(index);
1444 mConfig.setValue(ConfigOptions::pluginInfoPathString(), pluginInfo.path());
1445 mConfig.setValue(ConfigOptions::pluginInfoTypeString(), static_cast<int>(pluginInfo.type()));
1446 mConfig.setValue(ConfigOptions::pluginInfoVersionString(), pluginInfo.version());
1447 }
1448 mConfig.endArray();
1449 emit pluginsChanged();
1450 }
1451
1452 bool Config::customPluginSearchPathEnabled() const
1453 {
1454 return loadValue(ConfigOptions::customPluginSearchPathEnabledString(), false).toBool();
1455 }
1456
1457 void Config::setCustomPluginSearchPathEnabled(bool enabled)
1458 {
1459 if (customPluginSearchPathEnabled() == enabled) {
1460 return;
1461 }
1462 saveValue(ConfigOptions::customPluginSearchPathEnabledString(), enabled);
1463 }
1464
1465 // Misc
1466
1467 void Config::saveValue(const QString &key, const QVariant &value)
1468 {
1469 mConfig.setValue(key, value);
1470 mConfig.sync();
1471 }
1472
1473 QVariant Config::loadValue(const QString &key, const QVariant &defaultValue) const
1474 {
1475 return mConfig.value(key, defaultValue);
1476 }