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 "rawpage.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 <ksharedconfig.h>
0029 #include <kconfiggroup.h>
0030 #include <klocalizedstring.h>
0031 
0032 // Local includes
0033 
0034 #include "dlayoutbox.h"
0035 
0036 namespace Digikam
0037 {
0038 
0039 class Q_DECL_HIDDEN RawPage::Private
0040 {
0041 public:
0042 
0043     explicit Private()
0044       : openDirectly(nullptr),
0045         useRawImport(nullptr),
0046         rawHandling(nullptr)
0047     {
0048     }
0049 
0050     QRadioButton* openDirectly;
0051     QRadioButton* useRawImport;
0052     QButtonGroup* rawHandling;
0053 };
0054 
0055 RawPage::RawPage(QWizard* const dlg)
0056     : DWizardPage(dlg, i18n("<b>Configure Raw File Handling</b>")),
0057       d(new Private)
0058 {
0059     const int spacing       = qMin(QApplication::style()->pixelMetric(QStyle::PM_LayoutHorizontalSpacing),
0060                              QApplication::style()->pixelMetric(QStyle::PM_LayoutVerticalSpacing));
0061 
0062     DVBox* const vbox       = new DVBox(this);
0063     QLabel* const label1    = new QLabel(vbox);
0064     label1->setWordWrap(true);
0065     label1->setText(i18n("<qt>"
0066                          "<p>Set here how you want to open Raw images in the editor:</p>"
0067                          "</qt>"));
0068 
0069     QWidget* const btns     = new QWidget(vbox);
0070     QVBoxLayout* const vlay = new QVBoxLayout(btns);
0071 
0072     d->rawHandling          = new QButtonGroup(btns);
0073     d->openDirectly         = new QRadioButton(btns);
0074     d->openDirectly->setText(i18n("Open directly, with adjustments made automatically"));
0075     d->openDirectly->setChecked(true);
0076     d->rawHandling->addButton(d->openDirectly);
0077 
0078     d->useRawImport         = new QRadioButton(btns);
0079     d->useRawImport->setText(i18n("Use the Raw import tool to adjust corrections manually"));
0080     d->rawHandling->addButton(d->useRawImport);
0081 
0082     vlay->addWidget(d->openDirectly);
0083     vlay->addWidget(d->useRawImport);
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> the Raw import tool is designed for advanced users who "
0091                          "want to have the best control over the image. "
0092                          "This requires more time in your workflow.</p>"
0093                          "</qt>"));
0094 
0095     setPageWidget(vbox);
0096     setLeftBottomPix(QIcon::fromTheme(QLatin1String("image-x-adobe-dng")));
0097 }
0098 
0099 RawPage::~RawPage()
0100 {
0101     delete d;
0102 }
0103 
0104 void RawPage::saveSettings()
0105 {
0106     KSharedConfig::Ptr config = KSharedConfig::openConfig();
0107     KConfigGroup group        = config->group(QLatin1String("ImageViewer Settings"));
0108     group.writeEntry(QLatin1String("UseRawImportTool"), d->useRawImport->isChecked());
0109     config->sync();
0110 }
0111 
0112 } // namespace Digikam
0113 
0114 #include "moc_rawpage.cpp"