1 /* ============================================================
2 *
3 * This file is a part of digiKam project
4 * https://www.digikam.org
5 *
6 * Date : 2009-08-12
7 * Description : methods that implement color management tasks
8 *
9 * Copyright (C) 2005-2006 by F.J. Cruz <fj dot cruz at supercable dot es>
10 * Copyright (C) 2005-2021 by Gilles Caulier <caulier dot gilles at gmail dot com>
11 * Copyright (C) 2009-2012 by Marcel Wiesweg <marcel dot wiesweg at gmx dot de>
12 *
13 * This program is free software; you can redistribute it
14 * and/or modify it under the terms of the GNU General
15 * Public License as published by the Free Software Foundation;
16 * either version 2, or (at your option)
17 * any later version.
18 *
19 * This program is distributed in the hope that it will be useful,
20 * but WITHOUT ANY WARRANTY; without even the implied warranty of
21 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
22 * GNU General Public License for more details.
23 *
24 * ============================================================ */
25
26 #include "iccpostloadingmanager.h"
27
28 // Qt includes
29
30 #include <QPointer>
31
32 // Local includes
33
34 #include "digikam_debug.h"
35 #include "colorcorrectiondlg.h"
36 #include "iccprofile.h"
37 #include "icctransform.h"
38
39 namespace Digikam
40 {
41
IccPostLoadingManager(DImg & image,const QString & filePath,const ICCSettingsContainer & settings)42 IccPostLoadingManager::IccPostLoadingManager(DImg& image, const QString& filePath, const ICCSettingsContainer& settings)
43 : IccManager(image, settings),
44 m_filePath(filePath)
45 {
46 }
47
postLoadingManage(QWidget * const parent)48 IccTransform IccPostLoadingManager::postLoadingManage(QWidget* const parent)
49 {
50 if (image().hasAttribute(QLatin1String("missingProfileAskUser")))
51 {
52 image().removeAttribute(QLatin1String("missingProfileAskUser"));
53 DImg preview = image().smoothScale(240, 180, Qt::KeepAspectRatio);
54 QPointer<ColorCorrectionDlg> dlg = new ColorCorrectionDlg(ColorCorrectionDlg::MissingProfile, preview,
55 m_filePath, parent);
56 dlg->exec();
57
58 IccTransform trans;
59 getTransform(trans, dlg->behavior(), dlg->specifiedProfile());
60 delete dlg;
61
62 return trans;
63 }
64 else if (image().hasAttribute(QLatin1String("profileMismatchAskUser")))
65 {
66 image().removeAttribute(QLatin1String("profileMismatchAskUser"));
67 DImg preview = image().smoothScale(240, 180, Qt::KeepAspectRatio);
68 QPointer<ColorCorrectionDlg> dlg = new ColorCorrectionDlg(ColorCorrectionDlg::ProfileMismatch, preview,
69 m_filePath, parent);
70 dlg->exec();
71
72 IccTransform trans;
73 getTransform(trans, dlg->behavior(), dlg->specifiedProfile());
74 delete dlg;
75
76 return trans;
77 }
78 else if (image().hasAttribute(QLatin1String("uncalibratedColorAskUser")))
79 {
80 image().removeAttribute(QLatin1String("uncalibratedColorAskUser"));
81 DImg preview = image().smoothScale(240, 180, Qt::KeepAspectRatio);
82 QPointer<ColorCorrectionDlg> dlg = new ColorCorrectionDlg(ColorCorrectionDlg::UncalibratedColor, preview,
83 m_filePath, parent);
84 dlg->exec();
85
86 IccTransform trans;
87 getTransform(trans, dlg->behavior(), dlg->specifiedProfile());
88 delete dlg;
89
90 return trans;
91 }
92
93 return IccTransform();
94 }
95
96 } // namespace Digikam
97