File indexing completed on 2025-01-05 03:57:13

0001 /* ============================================================
0002  *
0003  * This file is a part of digiKam project
0004  * https://www.digikam.org
0005  *
0006  * Date        : 2003-16-10
0007  * Description : application settings interface
0008  *
0009  * SPDX-FileCopyrightText: 2003-2004 by Renchi Raju <renchi dot raju at gmail dot com>
0010  * SPDX-FileCopyrightText: 2003-2024 by Gilles Caulier <caulier dot gilles at gmail dot com>
0011  * SPDX-FileCopyrightText: 2007      by Arnd Baecker <arnd dot baecker at web dot de>
0012  * SPDX-FileCopyrightText: 2014-2015 by Mohamed_Anwer <m_dot_anwer at gmx dot com>
0013  * SPDX-FileCopyrightText: 2017      by Simon Frei <freisim93 at gmail dot com>
0014  *
0015  * SPDX-License-Identifier: GPL-2.0-or-later
0016  *
0017  * ============================================================ */
0018 
0019 #ifndef DIGIKAM_APPLICATION_SETTINGS_H
0020 #define DIGIKAM_APPLICATION_SETTINGS_H
0021 
0022 // Qt includes
0023 
0024 #include <QFont>
0025 #include <QHash>
0026 #include <QObject>
0027 #include <QString>
0028 #include <QStringList>
0029 
0030 // Local includes
0031 
0032 #include "digikam_config.h"
0033 #include "sidebar.h"
0034 #include "dbengineparameters.h"
0035 #include "versionmanager.h"
0036 #include "digikam_export.h"
0037 #include "haariface.h"
0038 
0039 class KConfigGroup;
0040 
0041 namespace Digikam
0042 {
0043 
0044 class DbEngineParameters;
0045 class VersionManagerSettings;
0046 class PreviewSettings;
0047 
0048 class DIGIKAM_GUI_EXPORT ApplicationSettings : public QObject
0049 {
0050     Q_OBJECT
0051 
0052 public:
0053 
0054     enum AlbumSortRole
0055     {
0056         ByFolder = 0,
0057         ByCategory,
0058         ByDate
0059     };
0060 
0061     enum ItemLeftClickAction
0062     {
0063         ShowPreview = 0,
0064         StartEditor,
0065         ShowOnTable,
0066         OpenDefault,
0067     };
0068 
0069     /**
0070      * Possible ways of comparing strings.
0071      */
0072     enum StringComparisonType
0073     {
0074         /**
0075          * Natural compare using KStringHandler::naturalCompare.
0076          */
0077         Natural = 0,
0078 
0079         /**
0080          * Normal comparison using Qt's compare function.
0081          */
0082         Normal
0083     };
0084 
0085     /**
0086      * Types of operations
0087      * Originally introduced for grouping to configure whether an operation
0088      * should be done on all group members or only it's head.
0089      */
0090     enum OperationType
0091     {
0092         Metadata = 0,
0093         ImportExport,
0094         BQM,
0095         LightTable,
0096         Slideshow,
0097         Rename,
0098         Tools,
0099         Unspecified ///< This element must always come last
0100     };
0101 
0102     enum ApplyToEntireGroup
0103     {
0104         No = 0,
0105         Yes,
0106         Ask
0107     };
0108 
0109     typedef QHash<ApplicationSettings::OperationType, QString> OperationStrings;
0110     typedef QHash<ApplicationSettings::OperationType, ApplicationSettings::ApplyToEntireGroup> OperationModes;
0111 
0112 Q_SIGNALS:
0113 
0114     void setupChanged();
0115     void recurseSettingsChanged();
0116     void balooSettingsChanged();
0117 
0118 public:
0119 
0120     static ApplicationSettings* instance();
0121 
0122     void readSettings();
0123     void saveSettings();
0124     void emitSetupChanged();
0125 
0126     QString generalConfigGroupName() const;
0127 
0128     // -- MessageBox Notification ---------------------------------------------------
0129 
0130     /**
0131      * @return true if the corresponding message box should be shown.
0132      * @param dontShowAgainName the name that identify the message box.
0133      */
0134     bool readMsgBoxShouldBeShown(const QString& dontShowAgainName);
0135 
0136     /**
0137      * Save the fact that the message box should not be shown again.
0138      * @param dontShowAgainName the name that identify the message box. If
0139      * empty, this method does nothing.
0140      */
0141     void saveMsgBoxShouldBeShown(const QString& dontShowAgainName);
0142 
0143     // -- Database Settings ---------------------------------------------------------
0144 
0145     DbEngineParameters getDbEngineParameters() const;
0146     void setDbEngineParameters(const DbEngineParameters& params);
0147 
0148     void setSyncBalooToDigikam(bool val);
0149     bool getSyncBalooToDigikam() const;
0150 
0151     void setSyncDigikamToBaloo(bool val);
0152     bool getSyncDigikamToBaloo() const;
0153 
0154     // -- Albums Settings -------------------------------------------------------
0155 
0156     void setTreeViewIconSize(int val);
0157     int  getTreeViewIconSize() const;
0158 
0159     void setTreeViewFaceSize(int val);
0160     int  getTreeViewFaceSize() const;
0161 
0162     void setTreeViewFont(const QFont& font);
0163     QFont getTreeViewFont() const;
0164 
0165     void setAlbumSortRole(const AlbumSortRole role);
0166     AlbumSortRole getAlbumSortRole() const;
0167 
0168     void setAlbumSortChanged(bool val);
0169     bool getAlbumSortChanged() const;
0170 
0171     void setShowFolderTreeViewItemsCount(bool val);
0172     bool getShowFolderTreeViewItemsCount() const;
0173 
0174     void setAlbumMonitoring(bool val);
0175     bool getAlbumMonitoring() const;
0176 
0177     void setRecurseAlbums(bool val);
0178     bool getRecurseAlbums() const;
0179 
0180     void setRecurseTags(bool val);
0181     bool getRecurseTags() const;
0182 
0183     void setAllGroupsOpen(bool val);
0184     bool getAllGroupsOpen() const;
0185 
0186     void setAlbumCategoryNames(const QStringList& list);
0187     QStringList getAlbumCategoryNames() const;
0188 
0189     bool addAlbumCategoryName(const QString& name) const;
0190     bool delAlbumCategoryName(const QString& name) const;
0191 
0192     // -- Icon-View Settings -------------------------------------------------------
0193 
0194     void setDefaultIconSize(int val);
0195     int  getDefaultIconSize() const;
0196 
0197     void setIconViewFont(const QFont& font);
0198     QFont getIconViewFont() const;
0199 
0200     void setImageSortOrder(int order);
0201     int  getImageSortOrder() const;
0202 
0203     /**
0204      * means ascending or descending
0205      */
0206     void setImageSorting(int sorting);
0207     int  getImageSorting() const;
0208 
0209     void setImageSeparationMode(int mode);
0210     int  getImageSeparationMode() const;
0211 
0212     void setImageSeparationSortOrder(int order);
0213     int  getImageSeparationSortOrder() const;
0214 
0215     void setItemLeftClickAction(int action);
0216     int  getItemLeftClickAction() const;
0217 
0218     void setIconShowName(bool val);
0219     bool getIconShowName() const;
0220 
0221     void setIconShowSize(bool val);
0222     bool getIconShowSize() const;
0223 
0224     void setIconShowTitle(bool val);
0225     bool getIconShowTitle() const;
0226 
0227     void setIconShowComments(bool val);
0228     bool getIconShowComments() const;
0229 
0230     void setIconShowResolution(bool val);
0231     bool getIconShowResolution() const;
0232 
0233     void setIconShowAspectRatio(bool val);
0234     bool getIconShowAspectRatio() const;
0235 
0236     void setIconShowTags(bool val);
0237     bool getIconShowTags() const;
0238 
0239     void setIconShowDate(bool val);
0240     bool getIconShowDate() const;
0241 
0242     void setIconShowModDate(bool val);
0243     bool getIconShowModDate() const;
0244 
0245     void setIconShowRating(bool val);
0246     bool getIconShowRating() const;
0247 
0248     void setIconShowPickLabel(bool val);
0249     bool getIconShowPickLabel() const;
0250 
0251     void setIconShowColorLabel(bool val);
0252     bool getIconShowColorLabel() const;
0253 
0254     void setIconShowImageFormat(bool val);
0255     bool getIconShowImageFormat() const;
0256 
0257     void setIconShowCoordinates(bool val);
0258     bool getIconShowCoordinates() const;
0259 
0260     /**
0261      * Sets the visibility of the overlay buttons on the image icons.
0262      */
0263     void setIconShowOverlays(bool val);
0264 
0265     /**
0266      * Determines whether the overlay buttons should be displayed on the icons.
0267      */
0268     bool getIconShowOverlays() const;
0269 
0270     void setIconShowFullscreen(bool val);
0271     bool getIconShowFullscreen() const;
0272 
0273     void setPreviewSettings(const PreviewSettings& settings);
0274     PreviewSettings getPreviewSettings() const;
0275 
0276     void setPreviewShowIcons(bool val);
0277     bool getPreviewShowIcons() const;
0278 
0279     void setScaleFitToWindow(bool val);
0280     bool getScaleFitToWindow() const;
0281 
0282     // -- Mime-Types Settings -------------------------------------------------------
0283 
0284     QString getImageFileFilter() const;
0285     QString getMovieFileFilter() const;
0286     QString getAudioFileFilter() const;
0287     QString getRawFileFilter()   const;
0288     QString getAllFileFilter()   const;
0289 
0290     void addToImageFileFilter(const QString& extensions);
0291 
0292     // -- Tool-Tips Settings -------------------------------------------------------
0293 
0294     bool showToolTipsIsValid()      const;
0295     bool showAlbumToolTipsIsValid() const;
0296 
0297     void setToolTipsFont(const QFont& font);
0298     QFont getToolTipsFont() const;
0299 
0300     void setShowToolTips(bool val);
0301     bool getShowToolTips() const;
0302 
0303     void setToolTipsShowFileName(bool val);
0304     bool getToolTipsShowFileName() const;
0305 
0306     void setToolTipsShowFileDate(bool val);
0307     bool getToolTipsShowFileDate() const;
0308 
0309     void setToolTipsShowFileSize(bool val);
0310     bool getToolTipsShowFileSize() const;
0311 
0312     void setToolTipsShowImageType(bool val);
0313     bool getToolTipsShowImageType() const;
0314 
0315     void setToolTipsShowImageDim(bool val);
0316     bool getToolTipsShowImageDim() const;
0317 
0318     void setToolTipsShowImageAR(bool val);
0319     bool getToolTipsShowImageAR() const;
0320 
0321     void setToolTipsShowPhotoMake(bool val);
0322     bool getToolTipsShowPhotoMake() const;
0323 
0324     void setToolTipsShowPhotoLens(bool val);
0325     bool getToolTipsShowPhotoLens() const;
0326 
0327     void setToolTipsShowPhotoDate(bool val);
0328     bool getToolTipsShowPhotoDate() const;
0329 
0330     void setToolTipsShowPhotoFocal(bool val);
0331     bool getToolTipsShowPhotoFocal() const;
0332 
0333     void setToolTipsShowPhotoExpo(bool val);
0334     bool getToolTipsShowPhotoExpo() const;
0335 
0336     void setToolTipsShowPhotoMode(bool val);
0337     bool getToolTipsShowPhotoMode() const;
0338 
0339     void setToolTipsShowPhotoFlash(bool val);
0340     bool getToolTipsShowPhotoFlash() const;
0341 
0342     void setToolTipsShowPhotoWB(bool val);
0343     bool getToolTipsShowPhotoWB() const;
0344 
0345     void setToolTipsShowAlbumName(bool val);
0346     bool getToolTipsShowAlbumName() const;
0347 
0348     void setToolTipsShowTitles(bool val);
0349     bool getToolTipsShowTitles() const;
0350 
0351     void setToolTipsShowComments(bool val);
0352     bool getToolTipsShowComments() const;
0353 
0354     void setToolTipsShowTags(bool val);
0355     bool getToolTipsShowTags() const;
0356 
0357     void setToolTipsShowLabelRating(bool val);
0358     bool getToolTipsShowLabelRating() const;
0359 
0360     void setShowAlbumToolTips(bool val);
0361     bool getShowAlbumToolTips() const;
0362 
0363     void setToolTipsShowAlbumTitle(bool val);
0364     bool getToolTipsShowAlbumTitle() const;
0365 
0366     void setToolTipsShowAlbumDate(bool val);
0367     bool getToolTipsShowAlbumDate() const;
0368 
0369     void setToolTipsShowAlbumCollection(bool val);
0370     bool getToolTipsShowAlbumCollection() const;
0371 
0372     void setToolTipsShowAlbumCategory(bool val);
0373     bool getToolTipsShowAlbumCategory() const;
0374 
0375     void setToolTipsShowAlbumCaption(bool val);
0376     bool getToolTipsShowAlbumCaption() const;
0377 
0378     void setToolTipsShowAlbumPreview(bool val);
0379     bool getToolTipsShowAlbumPreview() const;
0380 
0381     void setToolTipsShowVideoAspectRatio(bool val);
0382     bool getToolTipsShowVideoAspectRatio() const;
0383 
0384     void setToolTipsShowVideoAudioBitRate(bool val);
0385     bool getToolTipsShowVideoAudioBitRate() const;
0386 
0387     void setToolTipsShowVideoAudioChannelType(bool val);
0388     bool getToolTipsShowVideoAudioChannelType() const;
0389 
0390     void setToolTipsShowVideoAudioCodec(bool val);
0391     bool getToolTipsShowVideoAudioCodec() const;
0392 
0393     void setToolTipsShowVideoDuration(bool val);
0394     bool getToolTipsShowVideoDuration() const;
0395 
0396     void setToolTipsShowVideoFrameRate(bool val);
0397     bool getToolTipsShowVideoFrameRate() const;
0398 
0399     void setToolTipsShowVideoVideoCodec(bool val);
0400     bool getToolTipsShowVideoVideoCodec() const;
0401 
0402     // -- Miscs Settings -------------------------------------------------------
0403 
0404     void setScanAtStart(bool val);
0405     bool getScanAtStart() const;
0406 
0407     void setCleanAtStart(bool val);
0408     bool getCleanAtStart() const;
0409 
0410     void setDatabaseDirSetAtCmd(bool val);
0411     bool getDatabaseDirSetAtCmd() const;
0412 
0413     void setUseTrash(bool val);
0414     bool getUseTrash() const;
0415 
0416     void setShowTrashDeleteDialog(bool val);
0417     bool getShowTrashDeleteDialog() const;
0418 
0419     void setShowPermanentDeleteDialog(bool val);
0420     bool getShowPermanentDeleteDialog() const;
0421 
0422     void setApplySidebarChangesDirectly(bool val);
0423     bool getApplySidebarChangesDirectly() const;
0424 
0425     void setUseNativeFileDialog(bool val);
0426     bool getUseNativeFileDialog() const;
0427 
0428     void setDrawFramesToGrouped(bool val);
0429     bool getDrawFramesToGrouped() const;
0430 
0431     void setExpandNewCurrentItem(bool val);
0432     bool getExpandNewCurrentItem() const;
0433 
0434     void setScrollItemToCenter(bool val);
0435     bool getScrollItemToCenter() const;
0436 
0437     void setShowOnlyPersonTagsInPeopleSidebar(bool val);
0438     bool showOnlyPersonTagsInPeopleSidebar() const;
0439 
0440     void setDetectFacesInNewImages(bool val);
0441     bool getDetectFacesInNewImages() const;
0442 
0443     /**
0444      * Defines the way in which string comparisons are performed.
0445      *
0446      * @param val new way to compare strings
0447      */
0448     void setStringComparisonType(ApplicationSettings::StringComparisonType val);
0449 
0450     /**
0451      * Tells in which way strings are compared at the moment.
0452      *
0453      * @return string comparison type to use.
0454      */
0455     StringComparisonType getStringComparisonType() const;
0456 
0457     bool isStringTypeNatural() const;
0458 
0459     void setApplicationStyle(const QString& style);
0460     QString getApplicationStyle() const;
0461 
0462     void setIconTheme(const QString& theme);
0463     QString getIconTheme() const;
0464 
0465     void setApplicationFont(const QFont& fnt);
0466     QFont getApplicationFont() const;
0467 
0468     void setShowSplashScreen(bool val);
0469     bool getShowSplashScreen() const;
0470 
0471     void setCurrentTheme(const QString& theme);
0472     QString getCurrentTheme() const;
0473 
0474     void setSidebarTitleStyle(DMultiTabBar::TextStyle style);
0475     DMultiTabBar::TextStyle getSidebarTitleStyle() const;
0476 
0477     int getUpdateType() const;
0478     void setUpdateType(int type);
0479 
0480     bool getUpdateWithDebug() const;
0481     void setUpdateWithDebug(bool dbg);
0482 
0483     void setVersionManagerSettings(const VersionManagerSettings& settings);
0484     VersionManagerSettings getVersionManagerSettings() const;
0485 
0486     double getFaceDetectionAccuracy() const;
0487     void setFaceDetectionAccuracy(double value);
0488 
0489     bool getFaceDetectionYoloV3() const;
0490     void setFaceDetectionYoloV3(bool yolo);
0491 
0492     void setShowThumbbar(bool val);
0493     bool getShowThumbbar() const;
0494 
0495     void setRatingFilterCond(int val);
0496     int  getRatingFilterCond() const;
0497 
0498     void setMinimumSimilarityBound(int val);
0499     int  getMinimumSimilarityBound() const;
0500 
0501     void setDuplicatesSearchLastMinSimilarity(int val);
0502     int  getDuplicatesSearchLastMinSimilarity() const;
0503 
0504     void setDuplicatesSearchLastMaxSimilarity(int val);
0505     int  getDuplicatesSearchLastMaxSimilarity() const;
0506 
0507     /**
0508      * Defines whether an operation should be performed on all grouped items
0509      * or just the head item.
0510      *
0511      * @param type Operation to be performed
0512      * @param applyAll Whether to apply to all images or just one, or ask
0513      */
0514     void setGroupingOperateOnAll(OperationType type, ApplyToEntireGroup applyAll);
0515 
0516     /**
0517      * Tells whether an operation should be performed on all grouped items
0518      * or just the head item.
0519      *
0520      * @param type Operation to be performed
0521      * @return Whether to apply to all images or just one, or ask
0522      */
0523     ApplyToEntireGroup getGroupingOperateOnAll(OperationType type) const;
0524 
0525     /**
0526      * Asks the user whether the operation should be performed on all grouped
0527      * images or just the first. Also supplies an option to remember the answer.
0528      *
0529      * @param type Operation to be performed
0530      * @return Whether to apply to all images or just one
0531      */
0532     bool askGroupingOperateOnAll(OperationType type);
0533 
0534     /**
0535      * Gives the translated title/short explanation of the operation
0536      *
0537      * @param type Operation to be performed
0538      * @return Translated operation title/short explanation
0539      */
0540     static QString operationTypeTitle(OperationType type);
0541 
0542     /**
0543      * Gives a translated explanation of the operation and an empty string,
0544      * if there is none (e.g. for tooltips)
0545      *
0546      * @param type Operation to be performed
0547      * @return Translated operation explanation
0548      */
0549     static QString operationTypeExplanation(OperationType type);
0550 
0551     void setDuplicatesAlbumTagRelation(int val);
0552     int  getDuplicatesAlbumTagRelation() const;
0553 
0554     void setDuplicatesReferenceImageSelectionMethod(HaarIface::RefImageSelMethod val);
0555     HaarIface::RefImageSelMethod getDuplicatesRefImageSelMethod() const;
0556 
0557     void setDuplicatesSearchRestrictions(int val);
0558     int  getDuplicatesSearchRestrictions() const;
0559 
0560     void setHelpBoxNotificationSeen(bool val);
0561     bool getHelpBoxNotificationSeen();
0562 
0563 private Q_SLOTS:
0564 
0565     void applyBalooSettings();
0566 
0567 private:
0568 
0569     // Disabled
0570     ApplicationSettings();
0571     explicit ApplicationSettings(QObject*) = delete;
0572     ~ApplicationSettings() override;
0573 
0574     KConfigGroup generalConfigGroup() const;
0575 
0576 private:
0577 
0578     friend class ApplicationSettingsCreator;
0579 
0580     class Private;
0581     Private* const d;
0582 };
0583 
0584 } // namespace Digikam
0585 
0586 #endif // DIGIKAM_APPLICATION_SETTINGS_H