1 /* ============================================================
2  *
3  * This file is a part of digiKam project
4  * https://www.digikam.org
5  *
6  * Date        : 2009-28-04
7  * Description : first run assistant dialog
8  *
9  * Copyright (C) 2009-2021 by Gilles Caulier <caulier dot gilles at gmail dot com>
10  *
11  * This program is free software; you can redistribute it
12  * and/or modify it under the terms of the GNU General
13  * Public License as published by the Free Software Foundation;
14  * either version 2, or (at your option)
15  * any later version.
16  *
17  * This program is distributed in the hope that it will be useful,
18  * but WITHOUT ANY WARRANTY; without even the implied warranty of
19  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
20  * GNU General Public License for more details.
21  *
22  * ============================================================ */
23 
24 #include "rawpage.h"
25 
26 // Qt includes
27 
28 #include <QLabel>
29 #include <QRadioButton>
30 #include <QButtonGroup>
31 #include <QVBoxLayout>
32 #include <QApplication>
33 #include <QStyle>
34 
35 // KDE includes
36 
37 #include <ksharedconfig.h>
38 #include <kconfiggroup.h>
39 #include <klocalizedstring.h>
40 
41 // Local includes
42 
43 #include "dlayoutbox.h"
44 
45 namespace Digikam
46 {
47 
48 class Q_DECL_HIDDEN RawPage::Private
49 {
50 public:
51 
Private()52     explicit Private()
53       : openDirectly(nullptr),
54         useRawImport(nullptr),
55         rawHandling(nullptr)
56     {
57     }
58 
59     QRadioButton* openDirectly;
60     QRadioButton* useRawImport;
61     QButtonGroup* rawHandling;
62 };
63 
RawPage(QWizard * const dlg)64 RawPage::RawPage(QWizard* const dlg)
65     : DWizardPage(dlg, i18n("<b>Configure Raw File Handling</b>")),
66       d(new Private)
67 {
68     const int spacing       = QApplication::style()->pixelMetric(QStyle::PM_DefaultLayoutSpacing);
69 
70     DVBox* const vbox       = new DVBox(this);
71     QLabel* const label1    = new QLabel(vbox);
72     label1->setWordWrap(true);
73     label1->setText(i18n("<qt>"
74                          "<p>Set here how you want to open Raw images in the editor:</p>"
75                          "</qt>"));
76 
77     QWidget* const btns     = new QWidget(vbox);
78     QVBoxLayout* const vlay = new QVBoxLayout(btns);
79 
80     d->rawHandling          = new QButtonGroup(btns);
81     d->openDirectly         = new QRadioButton(btns);
82     d->openDirectly->setText(i18n("Open directly, with adjustments made automatically"));
83     d->openDirectly->setChecked(true);
84     d->rawHandling->addButton(d->openDirectly);
85 
86     d->useRawImport         = new QRadioButton(btns);
87     d->useRawImport->setText(i18n("Use the Raw import tool to adjust corrections manually"));
88     d->rawHandling->addButton(d->useRawImport);
89 
90     vlay->addWidget(d->openDirectly);
91     vlay->addWidget(d->useRawImport);
92     vlay->setContentsMargins(spacing, spacing, spacing, spacing);
93     vlay->setSpacing(spacing);
94 
95     QLabel* const label2    = new QLabel(vbox);
96     label2->setWordWrap(true);
97     label2->setText(i18n("<qt>"
98                          "<p><i>Note:</i> the Raw import tool is designed for advanced users who "
99                          "want to have the best control over the image. "
100                          "This requires more time in your workflow.</p>"
101                          "</qt>"));
102 
103     setPageWidget(vbox);
104     setLeftBottomPix(QIcon::fromTheme(QLatin1String("image-x-adobe-dng")));
105 }
106 
~RawPage()107 RawPage::~RawPage()
108 {
109     delete d;
110 }
111 
saveSettings()112 void RawPage::saveSettings()
113 {
114     KSharedConfig::Ptr config = KSharedConfig::openConfig();
115     KConfigGroup group        = config->group(QLatin1String("ImageViewer Settings"));
116     group.writeEntry(QLatin1String("UseRawImportTool"), d->useRawImport->isChecked());
117     config->sync();
118 }
119 
120 } // namespace Digikam
121