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

0001 /* ============================================================
0002  *
0003  * This file is a part of digiKam project
0004  * https://www.digikam.org
0005  *
0006  * Date        : 2006-07-09
0007  * Description : item tool tip configuration setup tab
0008  *
0009  * SPDX-FileCopyrightText: 2006-2024 by Gilles Caulier <caulier dot gilles at gmail dot com>
0010  * SPDX-FileCopyrightText: 2013-2014 by Mohamed_Anwer <m_dot_anwer at gmx dot com>
0011  *
0012  * SPDX-License-Identifier: GPL-2.0-or-later
0013  *
0014  * ============================================================ */
0015 
0016 #include "showfotosetuptooltip.h"
0017 
0018 // Qt includes
0019 
0020 #include <QCheckBox>
0021 #include <QGroupBox>
0022 #include <QVBoxLayout>
0023 #include <QApplication>
0024 #include <QStyle>
0025 
0026 // KDE includes
0027 
0028 #include <klocalizedstring.h>
0029 
0030 // Local includes
0031 
0032 #include "dfontselect.h"
0033 #include "showfotosettings.h"
0034 
0035 using namespace Digikam;
0036 
0037 namespace ShowFoto
0038 {
0039 
0040 class Q_DECL_HIDDEN ShowfotoSetupToolTip::Private
0041 {
0042 public:
0043 
0044     explicit Private()
0045       : showFileDateBox  (nullptr),
0046         showFileNameBox  (nullptr),
0047         showFileSizeBox  (nullptr),
0048         showImageDimBox  (nullptr),
0049         showImageTypeBox (nullptr),
0050         showPhotoDateBox (nullptr),
0051         showPhotoExpoBox (nullptr),
0052         showPhotoFlashBox(nullptr),
0053         showPhotoFocalBox(nullptr),
0054         showPhotoMakeBox (nullptr),
0055         showPhotoLensBox (nullptr),
0056         showPhotoModeBox (nullptr),
0057         showPhotoWbBox   (nullptr),
0058         showToolTipsBox  (nullptr),
0059         fileSettingBox   (nullptr),
0060         photoSettingBox  (nullptr),
0061         fontSelect       (nullptr),
0062         settings         (nullptr)
0063     {
0064     }
0065 
0066     QCheckBox*            showFileDateBox;
0067     QCheckBox*            showFileNameBox;
0068     QCheckBox*            showFileSizeBox;
0069     QCheckBox*            showImageDimBox;
0070     QCheckBox*            showImageTypeBox;
0071     QCheckBox*            showPhotoDateBox;
0072     QCheckBox*            showPhotoExpoBox;
0073     QCheckBox*            showPhotoFlashBox;
0074     QCheckBox*            showPhotoFocalBox;
0075     QCheckBox*            showPhotoMakeBox;
0076     QCheckBox*            showPhotoLensBox;
0077     QCheckBox*            showPhotoModeBox;
0078     QCheckBox*            showPhotoWbBox;
0079     QCheckBox*            showToolTipsBox;
0080 
0081     QGroupBox*            fileSettingBox;
0082     QGroupBox*            photoSettingBox;
0083 
0084     DFontSelect*          fontSelect;
0085     ShowfotoSettings*     settings;
0086 };
0087 
0088 // --------------------------------------------------------
0089 
0090 ShowfotoSetupToolTip::ShowfotoSetupToolTip(QWidget* const parent)
0091     : QScrollArea(parent),
0092       d          (new Private)
0093 {
0094     QWidget* const panel      = new QWidget(viewport());
0095     setWidget(panel);
0096     setWidgetResizable(true);
0097 
0098     const int spacing         = qMin(QApplication::style()->pixelMetric(QStyle::PM_LayoutHorizontalSpacing),
0099                              QApplication::style()->pixelMetric(QStyle::PM_LayoutVerticalSpacing));
0100 
0101     QVBoxLayout* const layout = new QVBoxLayout(panel);
0102     d->showToolTipsBox        = new QCheckBox(i18n("Show Items' Toolti&ps With Thumbbar and Folder-View"), panel);
0103     d->showToolTipsBox->setWhatsThis(i18n("Set this option to display the image information when "
0104                                           "the mouse hovers over a thumbbar or folder-view item."));
0105 
0106     d->fontSelect             = new DFontSelect(i18n("Font:"), panel);
0107     d->fontSelect->setToolTip(i18n("Select here the font used to display text in tooltips."));
0108 
0109     // --------------------------------------------------------
0110 
0111     d->fileSettingBox           = new QGroupBox(i18n("File/Image Information"), panel);
0112     QVBoxLayout* const gLayout1 = new QVBoxLayout(d->fileSettingBox);
0113 
0114     d->showFileNameBox  = new QCheckBox(i18n("Show file name"), d->fileSettingBox);
0115     d->showFileNameBox->setWhatsThis( i18n("Set this option to display the image file name."));
0116 
0117     d->showFileDateBox  = new QCheckBox(i18n("Show file date"), d->fileSettingBox);
0118     d->showFileDateBox->setWhatsThis( i18n("Set this option to display the image file date."));
0119 
0120     d->showFileSizeBox  = new QCheckBox(i18n("Show file size"), d->fileSettingBox);
0121     d->showFileSizeBox->setWhatsThis( i18n("Set this option to display the image file size."));
0122 
0123     d->showImageTypeBox = new QCheckBox(i18n("Show image type"), d->fileSettingBox);
0124     d->showImageTypeBox->setWhatsThis( i18n("Set this option to display the image type."));
0125 
0126     d->showImageDimBox  = new QCheckBox(i18n("Show image dimensions"), d->fileSettingBox);
0127     d->showImageDimBox->setWhatsThis( i18n("Set this option to display the image dimensions in pixels."));
0128 
0129     gLayout1->addWidget(d->showFileNameBox);
0130     gLayout1->addWidget(d->showFileDateBox);
0131     gLayout1->addWidget(d->showFileSizeBox);
0132     gLayout1->addWidget(d->showImageTypeBox);
0133     gLayout1->addWidget(d->showImageDimBox);
0134     gLayout1->setContentsMargins(spacing, spacing, spacing, spacing);
0135     gLayout1->setSpacing(0);
0136 
0137     // --------------------------------------------------------
0138 
0139     d->photoSettingBox    = new QGroupBox(i18n("Photograph Information"), panel);
0140     QVBoxLayout* gLayout2 = new QVBoxLayout(d->photoSettingBox);
0141 
0142     d->showPhotoMakeBox  = new QCheckBox(i18n("Show camera make and model"), d->photoSettingBox);
0143     d->showPhotoMakeBox->setWhatsThis( i18n("Set this option to display the make and model of the "
0144                                             "camera with which the image has been taken."));
0145 
0146     d->showPhotoLensBox  = new QCheckBox(i18n("Camera lens model"), d->photoSettingBox);
0147     d->showPhotoLensBox->setWhatsThis(i18n("Set this option to display the lens model with "
0148                                            "which the image was taken."));
0149 
0150     d->showPhotoDateBox  = new QCheckBox(i18n("Show camera date"), d->photoSettingBox);
0151     d->showPhotoDateBox->setWhatsThis( i18n("Set this option to display the date when the image was taken."));
0152 
0153     d->showPhotoFocalBox = new QCheckBox(i18n("Show camera aperture and focal length"), d->photoSettingBox);
0154     d->showPhotoFocalBox->setWhatsThis( i18n("Set this option to display the camera aperture and focal settings "
0155                                         "used to take the image."));
0156 
0157     d->showPhotoExpoBox  = new QCheckBox(i18n("Show camera exposure and sensitivity"), d->photoSettingBox);
0158     d->showPhotoExpoBox->setWhatsThis( i18n("Set this option to display the camera exposure and sensitivity "
0159                                             "used to take the image."));
0160 
0161     d->showPhotoModeBox  = new QCheckBox(i18n("Show camera mode and program"), d->photoSettingBox);
0162     d->showPhotoModeBox->setWhatsThis( i18n("Set this option to display the camera mode and program "
0163                                             "used to take the image."));
0164 
0165     d->showPhotoFlashBox = new QCheckBox(i18n("Show camera flash settings"), d->photoSettingBox);
0166     d->showPhotoFlashBox->setWhatsThis( i18n("Set this option to display the camera flash settings "
0167                                         "used to take the image."));
0168 
0169     d->showPhotoWbBox    = new QCheckBox(i18n("Show camera white balance settings"), d->photoSettingBox);
0170     d->showPhotoWbBox->setWhatsThis( i18n("Set this option to display the camera white balance settings "
0171                                           "used to take the image."));
0172 
0173     gLayout2->addWidget(d->showPhotoMakeBox);
0174     gLayout2->addWidget(d->showPhotoLensBox);
0175     gLayout2->addWidget(d->showPhotoDateBox);
0176     gLayout2->addWidget(d->showPhotoFocalBox);
0177     gLayout2->addWidget(d->showPhotoExpoBox);
0178     gLayout2->addWidget(d->showPhotoModeBox);
0179     gLayout2->addWidget(d->showPhotoFlashBox);
0180     gLayout2->addWidget(d->showPhotoWbBox);
0181     gLayout2->setContentsMargins(spacing, spacing, spacing, spacing);
0182     gLayout2->setSpacing(0);
0183 
0184     layout->addWidget(d->showToolTipsBox);
0185     layout->addWidget(d->fontSelect);
0186     layout->addWidget(d->fileSettingBox);
0187     layout->addWidget(d->photoSettingBox);
0188     layout->addStretch();
0189     layout->setContentsMargins(spacing, spacing, spacing, spacing);
0190     layout->setSpacing(spacing);
0191 
0192     // --------------------------------------------------------
0193 
0194     connect(d->showToolTipsBox, SIGNAL(toggled(bool)),
0195             d->fileSettingBox, SLOT(setEnabled(bool)));
0196 
0197     connect(d->showToolTipsBox, SIGNAL(toggled(bool)),
0198             d->photoSettingBox, SLOT(setEnabled(bool)));
0199 
0200     connect(d->showToolTipsBox, SIGNAL(toggled(bool)),
0201             d->fontSelect, SLOT(setEnabled(bool)));
0202 
0203     // --------------------------------------------------------
0204 
0205     readSettings();
0206     adjustSize();
0207 }
0208 
0209 ShowfotoSetupToolTip::~ShowfotoSetupToolTip()
0210 {
0211     delete d;
0212 }
0213 
0214 void ShowfotoSetupToolTip::readSettings()
0215 {
0216     d->settings = ShowfotoSettings::instance();
0217 
0218     d->showToolTipsBox->setChecked(d->settings->getShowToolTip());
0219     d->fontSelect->setFont(d->settings->getToolTipFont());
0220 
0221     d->showFileNameBox->setChecked(d->settings->getShowFileName());
0222     d->showFileDateBox->setChecked(d->settings->getShowFileDate());
0223     d->showFileSizeBox->setChecked(d->settings->getShowFileSize());
0224     d->showImageTypeBox->setChecked(d->settings->getShowFileType());
0225     d->showImageDimBox->setChecked(d->settings->getShowFileDim());
0226 
0227     d->showPhotoMakeBox->setChecked(d->settings->getShowPhotoMake());
0228     d->showPhotoLensBox->setChecked(d->settings->getShowPhotoLens());
0229     d->showPhotoDateBox->setChecked(d->settings->getShowPhotoDate());
0230     d->showPhotoFocalBox->setChecked(d->settings->getShowPhotoFocal());
0231     d->showPhotoExpoBox->setChecked(d->settings->getShowPhotoExpo());
0232     d->showPhotoModeBox->setChecked(d->settings->getShowPhotoMode());
0233     d->showPhotoFlashBox->setChecked(d->settings->getShowPhotoFlash());
0234     d->showPhotoWbBox->setChecked(d->settings->getShowPhotoWB());
0235 
0236     d->fileSettingBox->setEnabled(d->settings->getShowToolTip());
0237     d->photoSettingBox->setEnabled(d->settings->getShowToolTip());
0238 }
0239 
0240 void ShowfotoSetupToolTip::applySettings()
0241 {
0242     d->settings->setShowToolTip(d->showToolTipsBox->isChecked());
0243     d->settings->setToolTipFont(d->fontSelect->font());
0244 
0245     d->settings->setShowFileName(d->showFileNameBox->isChecked());
0246     d->settings->setShowFileDate(d->showFileDateBox->isChecked());
0247     d->settings->setShowFileSize(d->showFileSizeBox->isChecked());
0248     d->settings->setShowFileType(d->showImageTypeBox->isChecked());
0249     d->settings->setShowFileDim(d->showImageDimBox->isChecked());
0250 
0251     d->settings->setShowPhotoMake(d->showPhotoMakeBox->isChecked());
0252     d->settings->setShowPhotoLens(d->showPhotoLensBox->isChecked());
0253     d->settings->setShowPhotoDate(d->showPhotoDateBox->isChecked());
0254     d->settings->setShowPhotoFocal(d->showPhotoFocalBox->isChecked());
0255     d->settings->setShowPhotoExpo(d->showPhotoExpoBox->isChecked());
0256     d->settings->setShowPhotoMode(d->showPhotoModeBox->isChecked());
0257     d->settings->setShowPhotoFlash(d->showPhotoFlashBox->isChecked());
0258     d->settings->setShowPhotoWB(d->showPhotoWbBox->isChecked());
0259 
0260     d->settings->syncConfig();
0261 }
0262 
0263 } // namespace ShowFoto
0264 
0265 #include "moc_showfotosetuptooltip.cpp"