~ubuntu-branches/ubuntu/saucy/digikam/saucy

« back to all changes in this revision

Viewing changes to libs/widgets/iccprofiles/iccprofilescombobox.cpp

  • Committer: Bazaar Package Importer
  • Author(s): Scott Kitterman
  • Date: 2010-12-21 23:19:11 UTC
  • mfrom: (1.2.33 upstream) (3.1.7 experimental)
  • Revision ID: james.westby@ubuntu.com-20101221231911-z9jip7s5aht1jqn9
Tags: 2:1.7.0-1ubuntu1
* Merge from Debian Experimental. Remaining Ubuntu changes:
  - Export .pot name and copy to plugins in debian/rules
  - Version build-depends on kipi-plugins-dev to ensure build is against the
    same version on all archs
* Drop debian/patches/kubuntu_01_linker.diff, incoporated upstream
* Remove patches directory and unused patches

Show diffs side-by-side

added added

removed removed

Lines of Context:
43
43
{
44
44
 
45
45
IccProfilesComboBox::IccProfilesComboBox(QWidget* parent)
46
 
                   : KDcrawIface::SqueezedComboBox( parent )
 
46
    : KDcrawIface::SqueezedComboBox( parent )
47
47
{
48
48
}
49
49
 
64
64
    QString fileName = info.fileName();
65
65
 
66
66
    QString description = profile.description();
 
67
 
67
68
    if (!description.isEmpty() && !fileName.isEmpty())
 
69
    {
68
70
        return i18nc("<Profile Description> (<File Name>)", "%1 (%2)", description, fileName);
 
71
    }
69
72
    else if (!fileName.isEmpty())
 
73
    {
70
74
        return fileName;
 
75
    }
71
76
    else
 
77
    {
72
78
        return QString();
 
79
    }
73
80
}
74
81
 
75
82
// if needed outside this class, make it a public static method in a namespace
80
87
    foreach (IccProfile profile, givenProfiles) // krazy:exclude=foreach
81
88
    {
82
89
        QString filePath = profile.filePath();
 
90
 
83
91
        if (!profile.description().isNull() && (filePath.isNull() || !filePaths.contains(filePath)) )
84
92
        {
85
93
            profiles << profile;
92
100
    foreach (IccProfile profile, profiles) // krazy:exclude=foreach
93
101
    {
94
102
        QString description = profileUserString(profile);
 
103
 
95
104
        if (description.isNull())
 
105
        {
96
106
            continue;
 
107
        }
97
108
 
98
109
        *returnedProfiles << profile;
99
110
        *userText << description;
107
118
    formatProfiles(givenProfiles, &profiles, &userDescription);
108
119
 
109
120
    for (int i=0; i<profiles.size(); i++)
 
121
    {
110
122
        addSqueezedItem(userDescription[i], QVariant::fromValue(profiles[i]));
 
123
    }
111
124
}
112
125
 
113
126
void IccProfilesComboBox::addProfileSqueezed(const IccProfile& profile, const QString& d)
114
127
{
115
128
    QString description = d;
 
129
 
116
130
    if (description.isNull())
 
131
    {
117
132
        description = profileUserString(profile);
 
133
    }
 
134
 
118
135
    addSqueezedItem(description, QVariant::fromValue(profile));
119
136
}
120
137
 
150
167
    }
151
168
 
152
169
    const int size = count();
 
170
 
153
171
    for (int i=0; i<size; i++)
154
172
    {
155
173
        if (itemData(i).value<IccProfile>() == profile)
158
176
            return;
159
177
        }
160
178
    }
 
179
 
161
180
    setCurrentIndex(-1);
162
181
}
163
182
 
164
183
// ------------------------------------------------------------------------------------------
165
184
 
166
185
IccProfilesMenuAction::IccProfilesMenuAction(const KIcon& icon, const QString& text, QObject* parent)
167
 
                     : KActionMenu(icon, text, parent),
168
 
                       m_parent(parent)
 
186
    : KActionMenu(icon, text, parent),
 
187
      m_parent(parent)
169
188
{
170
189
    m_mapper = new QSignalMapper(this);
171
 
    connect(m_mapper, SIGNAL(mapped(QObject*)), 
 
190
    connect(m_mapper, SIGNAL(mapped(QObject*)),
172
191
            this, SLOT(slotTriggered(QObject*)));
173
192
}
174
193
 
175
 
IccProfilesMenuAction::IccProfilesMenuAction(const QString &text, QObject* parent)
176
 
                     : KActionMenu(text, parent),
177
 
                       m_parent(parent)
 
194
IccProfilesMenuAction::IccProfilesMenuAction(const QString& text, QObject* parent)
 
195
    : KActionMenu(text, parent),
 
196
      m_parent(parent)
178
197
{
179
198
    m_mapper = new QSignalMapper(this);
180
199
    connect(m_mapper, SIGNAL(mapped(QObject*)),
207
226
void IccProfilesMenuAction::addProfile(const IccProfile& profile, const QString& d)
208
227
{
209
228
    QString description = d;
 
229
 
210
230
    if (description.isNull())
 
231
    {
211
232
        description = profileUserString(profile);
 
233
    }
212
234
 
213
235
    KAction* action = new KAction(d.left(50), m_parent);
214
236
    action->setData(QVariant::fromValue(profile));
215
237
    addAction(action);
216
238
 
217
 
    connect(action, SIGNAL(triggered()), 
 
239
    connect(action, SIGNAL(triggered()),
218
240
            m_mapper, SLOT(map()));
219
241
 
220
242
    m_mapper->setMapping(action, action);
223
245
void IccProfilesMenuAction::disableIfEmpty()
224
246
{
225
247
    if (menu()->isEmpty())
 
248
    {
226
249
        setEnabled(false);
 
250
    }
227
251
}
228
252
 
229
253
void IccProfilesMenuAction::slotTriggered(QObject* obj)
230
254
{
231
255
    KAction* action = static_cast<KAction*>(obj);
232
256
    IccProfile profile = action->data().value<IccProfile>();
 
257
 
233
258
    if (!profile.isNull())
 
259
    {
234
260
        emit triggered(profile);
 
261
    }
235
262
}
236
263
 
237
264
// ------------------------------------------------------------------------------------------
238
265
 
239
266
IccRenderingIntentComboBox::IccRenderingIntentComboBox(QWidget* parent)
240
 
                          : KComboBox(parent)
 
267
    : KComboBox(parent)
241
268
{
242
269
    addItem("Perceptual", IccTransform::Perceptual);
243
270
    addItem("Relative Colorimetric", IccTransform::RelativeColorimetric);
244
271
    addItem("Absolute Colorimetric", IccTransform::AbsoluteColorimetric);
245
272
    addItem("Saturation", IccTransform::Saturation);
246
273
    setWhatsThis( i18n("<ul><li><p><b>Perceptual intent</b> causes the full gamut of the image to be "
247
 
                     "compressed or expanded to fill the gamut of the destination device, so that gray balance is "
248
 
                     "preserved but colorimetric accuracy may not be preserved.</p>"
249
 
                     "<p>In other words, if certain colors in an image fall outside of the range of colors that the output "
250
 
                     "device can render, the image intent will cause all the colors in the image to be adjusted so that "
251
 
                     "the every color in the image falls within the range that can be rendered and so that the relationship "
252
 
                     "between colors is preserved as much as possible.</p>"
253
 
                     "<p>This intent is most suitable for display of photographs and images, and is the default intent.</p></li>"
254
 
                     "<li><p><b>Absolute Colorimetric intent</b> causes any colors that fall outside the range that the output device "
255
 
                     "can render to be adjusted to the closest color that can be rendered, while all other colors are "
256
 
                     "left unchanged.</p>"
257
 
                     "<p>This intent preserves the white point and is most suitable for spot colors (Pantone, TruMatch, "
258
 
                     "logo colors, ....)</p></li>"
259
 
                     "<li><p><b>Relative Colorimetric intent</b> is defined such that any colors that fall outside the range that the "
260
 
                     "output device can render are adjusted to the closest color that can be rendered, while all other colors "
261
 
                     "are left unchanged. Proof intent does not preserve the white point.</p></li>"
262
 
                     "<li><p><b>Saturation intent</b> preserves the saturation of colors in the image at the possible expense of "
263
 
                     "hue and lightness.</p>"
264
 
                     "<p>Implementation of this intent remains somewhat problematic, and the ICC is still working on methods to "
265
 
                     "achieve the desired effects.</p>"
266
 
                     "<p>This intent is most suitable for business graphics such as charts, where it is more important that the "
267
 
                     "colors be vivid and contrast well with each other rather than a specific color.</p></li></ul>"));
 
274
                       "compressed or expanded to fill the gamut of the destination device, so that gray balance is "
 
275
                       "preserved but colorimetric accuracy may not be preserved.</p>"
 
276
                       "<p>In other words, if certain colors in an image fall outside of the range of colors that the output "
 
277
                       "device can render, the image intent will cause all the colors in the image to be adjusted so that "
 
278
                       "the every color in the image falls within the range that can be rendered and so that the relationship "
 
279
                       "between colors is preserved as much as possible.</p>"
 
280
                       "<p>This intent is most suitable for display of photographs and images, and is the default intent.</p></li>"
 
281
                       "<li><p><b>Absolute Colorimetric intent</b> causes any colors that fall outside the range that the output device "
 
282
                       "can render to be adjusted to the closest color that can be rendered, while all other colors are "
 
283
                       "left unchanged.</p>"
 
284
                       "<p>This intent preserves the white point and is most suitable for spot colors (Pantone, TruMatch, "
 
285
                       "logo colors, ....)</p></li>"
 
286
                       "<li><p><b>Relative Colorimetric intent</b> is defined such that any colors that fall outside the range that the "
 
287
                       "output device can render are adjusted to the closest color that can be rendered, while all other colors "
 
288
                       "are left unchanged. Proof intent does not preserve the white point.</p></li>"
 
289
                       "<li><p><b>Saturation intent</b> preserves the saturation of colors in the image at the possible expense of "
 
290
                       "hue and lightness.</p>"
 
291
                       "<p>Implementation of this intent remains somewhat problematic, and the ICC is still working on methods to "
 
292
                       "achieve the desired effects.</p>"
 
293
                       "<p>This intent is most suitable for business graphics such as charts, where it is more important that the "
 
294
                       "colors be vivid and contrast well with each other rather than a specific color.</p></li></ul>"));
268
295
}
269
296
 
270
297
void IccRenderingIntentComboBox::setIntent(int intent)
271
298
{
272
299
    const int size = count();
 
300
 
273
301
    for (int i=0; i<size; i++)
274
302
    {
275
303
        if (itemData(i).toInt() == intent)
278
306
            return;
279
307
        }
280
308
    }
 
309
 
281
310
    setCurrentIndex(-1);
282
311
}
283
312