File indexing completed on 2025-01-05 03:58:23

0001 /* ============================================================
0002  *
0003  * This file is a part of digiKam project
0004  * https://www.digikam.org
0005  *
0006  * Date        : 2009-28-04
0007  * Description : first run assistant dialog
0008  *
0009  * SPDX-FileCopyrightText: 2009-2024 by Gilles Caulier <caulier dot gilles at gmail dot com>
0010  *
0011  * SPDX-License-Identifier: GPL-2.0-or-later
0012  *
0013  * ============================================================ */
0014 
0015 #include "metadatapage.h"
0016 
0017 // Qt includes
0018 
0019 #include <QLabel>
0020 #include <QRadioButton>
0021 #include <QButtonGroup>
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 "dlayoutbox.h"
0033 #include "metaenginesettings.h"
0034 
0035 namespace Digikam
0036 {
0037 
0038 class Q_DECL_HIDDEN MetadataPage::Private
0039 {
0040 public:
0041 
0042     explicit Private()
0043       : doNothing(nullptr),
0044         storeInFiles(nullptr),
0045         metadataStorage(nullptr)
0046     {
0047     }
0048 
0049     QRadioButton* doNothing;
0050     QRadioButton* storeInFiles;
0051     QButtonGroup* metadataStorage;
0052 };
0053 
0054 MetadataPage::MetadataPage(QWizard* const dlg)
0055     : DWizardPage(dlg, i18n("<b>Configure Metadata Storage to Files</b>")),
0056       d(new Private)
0057 {
0058     const int spacing        = qMin(QApplication::style()->pixelMetric(QStyle::PM_LayoutHorizontalSpacing),
0059                              QApplication::style()->pixelMetric(QStyle::PM_LayoutVerticalSpacing));
0060 
0061     DVBox* const vbox        = new DVBox(this);
0062     QLabel* const label1     = new QLabel(vbox);
0063     label1->setWordWrap(true);
0064     label1->setText(i18n("<qt>"
0065                          "<p>Set here if you want to store the information assigned to items in digiKam in the files' "
0066                          "metadata, to improve interoperability with other photo management programs:</p>"
0067                          "</qt>"));
0068 
0069     QWidget* const btns      = new QWidget(vbox);
0070     QVBoxLayout* const vlay  = new QVBoxLayout(btns);
0071 
0072     d->metadataStorage       = new QButtonGroup(btns);
0073     d->doNothing             = new QRadioButton(btns);
0074     d->doNothing->setText(i18n("Do nothing"));
0075     d->doNothing->setChecked(true);
0076     d->metadataStorage->addButton(d->doNothing);
0077 
0078     d->storeInFiles          = new QRadioButton(btns);
0079     d->storeInFiles->setText(i18n("Add information to files"));
0080     d->metadataStorage->addButton(d->storeInFiles);
0081 
0082     vlay->addWidget(d->doNothing);
0083     vlay->addWidget(d->storeInFiles);
0084     vlay->setContentsMargins(spacing, spacing, spacing, spacing);
0085     vlay->setSpacing(spacing);
0086 
0087     QLabel* const label2     = new QLabel(vbox);
0088     label2->setWordWrap(true);
0089     label2->setText(i18n("<qt>"
0090                          "<p><i>Note:</i> recording information to the files' metadata can slow down photo "
0091                          "management operations.</p>"
0092                          "</qt>"));
0093 
0094     setPageWidget(vbox);
0095     setLeftBottomPix(QIcon::fromTheme(QLatin1String("format-text-code")));
0096 }
0097 
0098 MetadataPage::~MetadataPage()
0099 {
0100     delete d;
0101 }
0102 
0103 void MetadataPage::saveSettings()
0104 {
0105     MetaEngineSettingsContainer settings;
0106     settings.saveTags       = d->storeInFiles->isChecked();
0107     settings.saveComments   = d->storeInFiles->isChecked();
0108     settings.saveDateTime   = d->storeInFiles->isChecked();
0109     settings.saveRating     = d->storeInFiles->isChecked();
0110     settings.savePickLabel  = d->storeInFiles->isChecked();
0111     settings.saveColorLabel = d->storeInFiles->isChecked();
0112     settings.saveTemplate   = d->storeInFiles->isChecked();
0113     MetaEngineSettings::instance()->setSettings(settings);
0114 }
0115 
0116 } // namespace Digikam
0117 
0118 #include "moc_metadatapage.cpp"