Changeset View
Changeset View
Standalone View
Standalone View
src/core-impl/collections/db/sql/SqlMeta.cpp
Show First 20 Lines • Show All 53 Lines • ▼ Show 20 Line(s) | |||||
54 | #include <QWriteLocker> | 54 | #include <QWriteLocker> | ||
55 | #include <QMutexLocker> | 55 | #include <QMutexLocker> | ||
56 | #include <QCryptographicHash> | 56 | #include <QCryptographicHash> | ||
57 | 57 | | |||
58 | #include <KCodecs> | 58 | #include <KCodecs> | ||
59 | #include <KLocalizedString> | 59 | #include <KLocalizedString> | ||
60 | #include <ThreadWeaver/Queue> | 60 | #include <ThreadWeaver/Queue> | ||
61 | 61 | | |||
62 | #include <thread> | ||||
63 | | ||||
64 | | ||||
62 | // additional constants | 65 | // additional constants | ||
63 | namespace Meta | 66 | namespace Meta | ||
64 | { | 67 | { | ||
65 | static const qint64 valAlbumId = valCustom + 1; | 68 | static const qint64 valAlbumId = valCustom + 1; | ||
66 | } | 69 | } | ||
67 | 70 | | |||
68 | using namespace Meta; | 71 | using namespace Meta; | ||
69 | 72 | | |||
▲ Show 20 Lines • Show All 1532 Lines • ▼ Show 20 Line(s) | 1604 | if( image.isNull() ) | |||
1602 | image = QImage( m_imagePath ); | 1605 | image = QImage( m_imagePath ); | ||
1603 | 1606 | | |||
1604 | if( image.isNull() ) | 1607 | if( image.isNull() ) | ||
1605 | return Meta::Album::image( size ); | 1608 | return Meta::Album::image( size ); | ||
1606 | 1609 | | |||
1607 | if( size > 1 && size < 1000 ) | 1610 | if( size > 1 && size < 1000 ) | ||
1608 | { | 1611 | { | ||
1609 | image = image.scaled( size, size, Qt::KeepAspectRatio, Qt::SmoothTransformation ); | 1612 | image = image.scaled( size, size, Qt::KeepAspectRatio, Qt::SmoothTransformation ); | ||
1610 | image.save( cachedImagePath, "PNG" ); | 1613 | std::thread thread( QOverload<const QString&, const char*, int>::of( &QImage::save ), image, cachedImagePath, "PNG", -1 ); | ||
1614 | thread.detach(); | ||||
1611 | } | 1615 | } | ||
1612 | 1616 | | |||
1613 | return image; | 1617 | return image; | ||
1614 | } | 1618 | } | ||
1615 | 1619 | | |||
1616 | QUrl | 1620 | QUrl | ||
1617 | SqlAlbum::imageLocation( int size ) | 1621 | SqlAlbum::imageLocation( int size ) | ||
1618 | { | 1622 | { | ||
Show All 39 Lines | 1652 | { | |||
1658 | // and remove references from the database if required. | 1662 | // and remove references from the database if required. | ||
1659 | removeImage(); | 1663 | removeImage(); | ||
1660 | 1664 | | |||
1661 | QString path = largeDiskCachePath(); | 1665 | QString path = largeDiskCachePath(); | ||
1662 | // make sure not to overwrite existing images | 1666 | // make sure not to overwrite existing images | ||
1663 | while( QFile(path).exists() ) | 1667 | while( QFile(path).exists() ) | ||
1664 | path += '_'; // not that nice but it shouldn't happen that often. | 1668 | path += '_'; // not that nice but it shouldn't happen that often. | ||
1665 | 1669 | | |||
1666 | image.save( path, "JPG" ); | 1670 | std::thread thread( QOverload<const QString&, const char*, int>::of( &QImage::save ), image, path, "JPG", -1 ); | ||
1671 | thread.detach(); | ||||
1667 | setImage( path ); | 1672 | setImage( path ); | ||
1668 | 1673 | | |||
1669 | locker.unlock(); | 1674 | locker.unlock(); | ||
1670 | notifyObservers(); | 1675 | notifyObservers(); | ||
1671 | 1676 | | |||
1672 | // -- write back the album cover if allowed | 1677 | // -- write back the album cover if allowed | ||
1673 | if( AmarokConfig::writeBackCover() ) | 1678 | if( AmarokConfig::writeBackCover() ) | ||
1674 | { | 1679 | { | ||
▲ Show 20 Lines • Show All 573 Lines • Show Last 20 Lines |