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

« back to all changes in this revision

Viewing changes to libs/dimg/filters/icc/iccsettings.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:
64
64
{
65
65
public:
66
66
 
67
 
    IccSettingsPriv(){}
 
67
    IccSettingsPriv() {}
68
68
 
69
69
    ICCSettingsContainer   settings;
70
70
    QMutex                 mutex;
83
83
 
84
84
// -----------------------------------------------------------------------------------------------
85
85
 
86
 
class IccSettingsCreator { public: IccSettings object; };
 
86
class IccSettingsCreator
 
87
{
 
88
public:
 
89
    IccSettings object;
 
90
};
87
91
K_GLOBAL_STATIC(IccSettingsCreator, creator)
88
92
 
89
93
// -----------------------------------------------------------------------------------------------
90
94
 
91
 
IccSettings *IccSettings::instance()
 
95
IccSettings* IccSettings::instance()
92
96
{
93
97
    return &creator->object;
94
98
}
95
99
 
96
100
IccSettings::IccSettings()
97
 
           : d(new IccSettingsPriv)
 
101
    : d(new IccSettingsPriv)
98
102
{
99
103
    IccTransform::init();
100
104
    readFromConfig();
114
118
    return s;
115
119
}
116
120
 
117
 
IccProfile IccSettings::monitorProfile(QWidget *widget)
 
121
IccProfile IccSettings::monitorProfile(QWidget* widget)
118
122
{
119
123
    // system-wide profile set?
120
124
    IccProfile profile = d->profileFromWindowSystem(widget);
 
125
 
121
126
    if (!profile.isNull())
 
127
    {
122
128
        return profile;
 
129
    }
123
130
 
124
131
    QMutexLocker lock(&d->mutex);
 
132
 
125
133
    if (!d->settings.monitorProfile.isNull())
 
134
    {
126
135
        return d->settings.monitorProfile;
 
136
    }
127
137
    else
 
138
    {
128
139
        return IccProfile::sRGB();
 
140
    }
129
141
}
130
142
 
131
143
bool IccSettings::monitorProfileFromSystem()
133
145
    // First, look into cache
134
146
    {
135
147
        QMutexLocker lock(&d->mutex);
136
 
        foreach (const IccProfile &profile, d->screenProfiles)
 
148
        foreach (const IccProfile& profile, d->screenProfiles)
137
149
        {
138
150
            if (!profile.isNull())
139
151
            {
144
156
 
145
157
    // Second, check all toplevel widgets
146
158
    QList<QWidget*> topLevels = qApp->topLevelWidgets();
147
 
    foreach (QWidget *widget, topLevels)
 
159
    foreach (QWidget* widget, topLevels)
148
160
    {
149
161
        if (!d->profileFromWindowSystem(widget).isNull())
150
162
        {
163
175
 *  Copyright (C) 2007 Thomas Zander <zander@kde.org>
164
176
 *  Copyright (C) 2007 Adrian Page <adrian@pagenet.plus.com>IccProfile IccSettingsPriv::profileForScreen(QWidget *widget)
165
177
*/
166
 
IccProfile IccSettingsPriv::profileFromWindowSystem(QWidget *widget)
 
178
IccProfile IccSettingsPriv::profileFromWindowSystem(QWidget* widget)
167
179
{
168
180
#ifdef Q_WS_X11
169
181
 
170
182
    Qt::HANDLE appRootWindow;
171
183
    QString atomName;
172
184
 
173
 
    QDesktopWidget *desktop = QApplication::desktop();
 
185
    QDesktopWidget* desktop = QApplication::desktop();
174
186
    int screenNumber        = desktop->screenNumber(widget);
175
187
 
176
188
    IccProfile profile;
177
189
    {
178
190
        QMutexLocker lock(&mutex);
 
191
 
179
192
        if (screenProfiles.contains(screenNumber))
 
193
        {
180
194
            return screenProfiles.value(screenNumber);
 
195
        }
181
196
    }
182
197
 
183
198
    if (desktop->isVirtualDesktop())
201
216
 
202
217
    if  ( icc_atom != None &&
203
218
          XGetWindowProperty ( QX11Info::display(),
204
 
                    appRootWindow,
205
 
                    icc_atom,
206
 
                    0,
207
 
                    INT_MAX,
208
 
                    False,
209
 
                    XA_CARDINAL,
210
 
                    &type,
211
 
                    &format,
212
 
                    &nitems,
213
 
                    &bytes_after,
214
 
                    (unsigned char **) &str) == Success
215
 
            && nitems
216
 
                )
 
219
                               appRootWindow,
 
220
                               icc_atom,
 
221
                               0,
 
222
                               INT_MAX,
 
223
                               False,
 
224
                               XA_CARDINAL,
 
225
                               &type,
 
226
                               &format,
 
227
                               &nitems,
 
228
                               &bytes_after,
 
229
                               (unsigned char**) &str) == Success
 
230
          && nitems
 
231
        )
217
232
    {
218
233
        QByteArray bytes = QByteArray::fromRawData((char*)str, (quint32)nitems);
219
234
 
220
235
        if (!bytes.isEmpty())
 
236
        {
221
237
            profile = bytes;
 
238
        }
 
239
 
222
240
        kDebug() << "Found X.org XICC monitor profile" << profile.description();
223
241
    }
 
242
 
224
243
    //else
225
 
      //  kDebug() << "No X.org XICC profile installed for screen" << screenNumber;
 
244
    //  kDebug() << "No X.org XICC profile installed for screen" << screenNumber;
226
245
 
227
246
    // insert to cache even if null
228
247
    {
265
284
    ICCSettingsContainer old;
266
285
    {
267
286
        QMutexLocker lock(&d->mutex);
 
287
 
268
288
        if (settings.iccFolder != d->settings.iccFolder)
 
289
        {
269
290
            d->profiles.clear();
 
291
        }
270
292
 
271
293
        old         = d->settings;
272
294
        d->settings = settings;
285
307
        QMutexLocker lock(&d->mutex);
286
308
        old                        = d->settings;
287
309
        d->settings.useManagedView = useManagedView;
288
 
        current                    = d->settings;
 
310
        current            = d->settings;
289
311
    }
290
312
    KSharedConfig::Ptr config = KGlobal::config();
291
313
    KConfigGroup group        = config->group(QString("Color Management"));
299
321
    ICCSettingsContainer old, current;
300
322
    {
301
323
        QMutexLocker lock(&d->mutex);
 
324
 
302
325
        if (path == d->settings.iccFolder)
 
326
        {
303
327
            return;
 
328
        }
304
329
 
305
330
        d->profiles.clear();
306
331
        old                   = d->settings;
307
332
        d->settings.iccFolder = path;
308
 
        current               = d->settings;
 
333
        current           = d->settings;
309
334
    }
310
335
    KSharedConfig::Ptr config = KGlobal::config();
311
336
    KConfigGroup group        = config->group(QString("Color Management"));
324
349
    foreach (const QString& dirPath, dirs)
325
350
    {
326
351
        QDir dir(dirPath);
 
352
 
327
353
        if (!dir.exists())
 
354
        {
328
355
            continue;
 
356
        }
 
357
 
329
358
        scanDirectory(dir.path(), filters, &profiles);
330
359
    }
331
360
 
344
373
        {
345
374
            //kDebug() << info.filePath() << (info.exists() && info.isReadable());
346
375
            IccProfile profile(info.filePath());
 
376
 
347
377
            if (profile.open())
348
378
            {
349
379
                *profiles << profile;
 
380
 
350
381
                if (info.fileName() == "AdobeRGB1998.icc")
 
382
                {
351
383
                    IccProfile::considerOriginalAdobeRGB(info.filePath());
 
384
                }
352
385
            }
353
386
        }
354
387
        else if (info.isDir() && !info.isSymLink())
363
396
    QString extraPath;
364
397
    {
365
398
        QMutexLocker lock(&d->mutex);
 
399
 
366
400
        if (!d->profiles.isEmpty())
 
401
        {
367
402
            return d->profiles;
 
403
        }
368
404
 
369
405
        extraPath = d->settings.iccFolder;
370
406
    }
376
412
 
377
413
    // add user-specified path
378
414
    if (!extraPath.isEmpty() && !paths.contains(extraPath))
 
415
    {
379
416
        paths << extraPath;
 
417
    }
380
418
 
381
419
    // check search directories
382
420
    profiles << d->scanDirectories(paths);
413
451
    foreach (IccProfile profile, allProfiles()) // krazy:exclude=foreach
414
452
    {
415
453
        if (profile.type() == IccProfile::Display)
 
454
        {
416
455
            profiles << profile;
 
456
        }
417
457
    }
418
458
    return profiles;
419
459
}
441
481
    foreach (IccProfile profile, allProfiles()) // krazy:exclude=foreach
442
482
    {
443
483
        if (profile.type() == IccProfile::Output)
 
484
        {
444
485
            profiles << profile;
 
486
        }
445
487
    }
446
488
    return profiles;
447
489
}
450
492
{
451
493
    allProfiles();
452
494
    const int size = d->profiles.size();
 
495
 
453
496
    for (int i=0; i<size; ++i)
454
497
    {
455
498
        IccProfile& profile = d->profiles[i];
 
499
 
456
500
        if (!profile.isOpen())
457
501
        {
458
502
            profile.description();