Commit aaa82a10 authored by Gilles Caulier's avatar Gilles Caulier 🗼
Browse files

Add new option to support icon-view large thumb size (over 256x256 px)

If you use large screen resolution, as WQHD or 4K monitor, you can now use until 512x512 px size for thumbnails.
When this option is turned on/off from setings panel, user need to restart digiKam to take effect, and thumbnails
need to be rebuild over collection through MAntenance tool, to update digiKam thumbs database.
BUGS: 328430
FIXED-IN : 4.1.0
parent 20c3507b
......@@ -966,6 +966,7 @@ IF(DIGIKAM_CAN_BE_COMPILED)
${CMAKE_CURRENT_SOURCE_DIR}/libs/threadimageio/thumbnailcreator.cpp
${CMAKE_CURRENT_SOURCE_DIR}/libs/threadimageio/thumbnailloadthread.cpp
${CMAKE_CURRENT_SOURCE_DIR}/libs/threadimageio/thumbnailtask.cpp
${CMAKE_CURRENT_SOURCE_DIR}/libs/threadimageio/thumbnailsize.cpp
)
SET(libcommonwidgets_SRCS
......
......@@ -542,7 +542,7 @@ int ImageDelegate::calculatethumbSizeToFit(int ws)
double rs1 = fmod((double)ws, (double)gs);
for (ts1 = ts ; ts1 < ThumbnailSize::Huge ; ++ts1)
for (ts1 = ts ; ts1 < ThumbnailSize::maxThumbsSize() ; ++ts1)
{
ngs = ts1 + 2*(d->margin + d->radius) + sp;
double nrs = fmod((double)ws, (double)ngs);
......
......@@ -443,6 +443,9 @@ AlbumSettings::AlbumSettings()
d->config = KGlobal::config();
init();
readSettings();
// Init Max Thumbnail Size at startup.
ThumbnailSize::readSettings(generalConfigGroup());
}
AlbumSettings::~AlbumSettings()
......
......@@ -1362,9 +1362,9 @@ void DigikamView::setThumbSize(int size)
else if ( (viewMode() == StackedView::IconViewMode)
|| (viewMode() == StackedView::TableViewMode) )
{
if (size > ThumbnailSize::Huge)
if (size > ThumbnailSize::maxThumbsSize())
{
d->thumbSize = ThumbnailSize::Huge;
d->thumbSize = ThumbnailSize::maxThumbsSize();
}
else if (size < ThumbnailSize::Small)
{
......@@ -1413,7 +1413,7 @@ void DigikamView::toggleZoomActions()
d->parent->enableZoomMinusAction(true);
d->parent->enableZoomPlusAction(true);
if (d->thumbSize >= ThumbnailSize::Huge)
if (d->thumbSize >= ThumbnailSize::maxThumbsSize())
{
d->parent->enableZoomPlusAction(false);
}
......
......@@ -139,7 +139,7 @@ bool ColumnThumbnail::paint(QPainter* const painter, const QStyleOptionViewItem&
const int bestSize = qMax(size.width()/* + 2*/, size.height()/* + 2*/);
// However, digiKam limits the thumbnail size, so we also do that here
const int maxSize = qMin(bestSize, (int)ThumbnailSize::Huge);
const int maxSize = qMin(bestSize, (int)ThumbnailSize::maxThumbsSize());
const QString path = info.filePath();
QPixmap thumbnail;
......
......@@ -308,8 +308,8 @@ void LoadingCache::removeThumbnails()
void LoadingCache::setThumbnailCacheSize(int numberOfQImages, int numberOfQPixmaps)
{
d->thumbnailImageCache.setMaxCost(numberOfQImages * ThumbnailSize::Huge * ThumbnailSize::Huge * 4);
d->thumbnailPixmapCache.setMaxCost(numberOfQPixmaps * ThumbnailSize::Huge * ThumbnailSize::Huge * QPixmap::defaultDepth() / 8);
d->thumbnailImageCache.setMaxCost(numberOfQImages * ThumbnailSize::maxThumbsSize() * ThumbnailSize::maxThumbsSize() * 4);
d->thumbnailPixmapCache.setMaxCost(numberOfQPixmaps * ThumbnailSize::maxThumbsSize() * ThumbnailSize::maxThumbsSize() * QPixmap::defaultDepth() / 8);
}
void LoadingCache::setFileWatch(LoadingCacheFileWatch* watch)
......
......@@ -125,7 +125,7 @@ int ThumbnailCreator::Private::storageSize() const
// for thumbnail db it's always max size
if (onlyLargeThumbnails)
{
return ThumbnailSize::Huge;
return ThumbnailSize::maxThumbsSize();
}
else
{
......
......@@ -150,7 +150,8 @@ public:
/**
* If you plan to load thumbnail from the context of the threadimageio framework,
* you can specify the relevant parameters. They will be passed if a thumbnail
* is created by loading with DImg.
* is created by loading with DImg. ${CMAKE_CURRENT_SOURCE_DIR}/libs/threadimageio/thumbnailtask.cpp
* Note that DImg is not used in most cases (Raw files, JPEG)
*/
void setLoadingProperties(DImgLoaderObserver* const observer, const DRawDecoding& settings);
......
......@@ -108,7 +108,7 @@ public:
Private()
{
size = ThumbnailSize::Huge;
size = ThumbnailSize::maxThumbsSize();
wantPixmap = true;
highlight = true;
sendSurrogate = true;
......@@ -242,18 +242,18 @@ void ThumbnailLoadThread::setThumbnailSize(int size, bool forFace)
int ThumbnailLoadThread::maximumThumbnailSize()
{
return ThumbnailSize::Huge;
return ThumbnailSize::maxThumbsSize();
}
int ThumbnailLoadThread::maximumThumbnailPixmapSize(bool highlight)
{
if (highlight)
{
return ThumbnailSize::Huge;
return ThumbnailSize::maxThumbsSize();
}
else
{
return ThumbnailSize::Huge + 2; // see slotThumbnailLoaded
return ThumbnailSize::maxThumbsSize() + 2; // see slotThumbnailLoaded
}
}
......@@ -669,10 +669,10 @@ bool ThumbnailLoadThread::checkSize(int size)
kError() << "ThumbnailLoadThread::load: No thumbnail size specified. Refusing to load thumbnail.";
return false;
}
else if (size > ThumbnailSize::Huge)
else if (size > ThumbnailSize::maxThumbsSize())
{
kError() << "ThumbnailLoadThread::load: Thumbnail size " << size
<< " is larger than " << ThumbnailSize::Huge << ". Refusing to load.";
<< " is larger than " << ThumbnailSize::maxThumbsSize() << ". Refusing to load.";
return false;
}
......
/* ============================================================
*
* This file is a part of digiKam project
* http://www.digikam.org
*
* Date : 2004-09-07
* Description : thumbnails size interface
*
* Copyright (C) 2005-2014 by Gilles Caulier <caulier dot gilles at gmail dot com>
*
* This program is free software; you can redistribute it
* and/or modify it under the terms of the GNU General
* Public License as published by the Free Software Foundation;
* either version 2, or (at your option)
* any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* ============================================================ */
#include "thumbnailsize.h"
namespace Digikam
{
static const QString s_configUseLargeThumbsEntry("Use Large Thumbs");
static bool s_useLargeThumbs = false;
ThumbnailSize::ThumbnailSize()
{
m_Size = Medium;
}
ThumbnailSize::ThumbnailSize(int size)
{
m_Size = size;
}
ThumbnailSize::ThumbnailSize(const ThumbnailSize& thumbsize)
{
m_Size = thumbsize.m_Size;
}
ThumbnailSize::~ThumbnailSize()
{
}
ThumbnailSize& ThumbnailSize::operator=(const ThumbnailSize& thumbsize)
{
m_Size = thumbsize.m_Size;
return *this;
}
bool ThumbnailSize::operator==(const ThumbnailSize& thumbsize) const
{
return m_Size == thumbsize.m_Size;
}
bool ThumbnailSize::operator!=(const ThumbnailSize& thumbsize) const
{
return m_Size != thumbsize.m_Size;
}
int ThumbnailSize::size() const
{
return m_Size;
}
// -- Static methods ---------------------------------------------------------
void ThumbnailSize::setUseLargeThumbs(bool val)
{
s_useLargeThumbs = val;
}
bool ThumbnailSize::getUseLargeThumbs()
{
return s_useLargeThumbs;
}
void ThumbnailSize::readSettings(const KConfigGroup& group)
{
setUseLargeThumbs(group.readEntry(s_configUseLargeThumbsEntry, false));
}
void ThumbnailSize::saveSettings(KConfigGroup& group, bool val)
{
group.writeEntry(s_configUseLargeThumbsEntry, val);
}
int ThumbnailSize::maxThumbsSize()
{
if (s_useLargeThumbs)
return ThumbnailSize::HD;
return ThumbnailSize::Huge;
}
} // namespace Digikam
......@@ -6,7 +6,8 @@
* Date : 2004-09-07
* Description : thumbnails size interface
*
* Copyright (C) 2004 by Renchi Raju <renchi dot raju at gmail dot com>
* Copyright (C) 2004 by Renchi Raju <renchi dot raju at gmail dot com>
* Copyright (C) 2005-2014 by Gilles Caulier <caulier dot gilles at gmail dot com>
*
* This program is free software; you can redistribute it
* and/or modify it under the terms of the GNU General
......@@ -24,10 +25,22 @@
#ifndef THUMBNAILSIZE_H
#define THUMBNAILSIZE_H
// Qt includes
#include <QString>
// KDE includes
#include <kconfiggroup.h>
// Local includes
#include "digikam_export.h"
namespace Digikam
{
class ThumbnailSize
class DIGIKAM_EXPORT ThumbnailSize
{
public:
......@@ -40,52 +53,35 @@ public:
Small = 80,
Medium = 128,
Large = 160,
Huge = 256
Huge = 256,
HD = 512
};
ThumbnailSize()
{
m_Size = Medium;
}
ThumbnailSize(int size)
{
m_Size = size;
}
public:
ThumbnailSize(const ThumbnailSize& thumbsize)
{
m_Size = thumbsize.m_Size;
}
ThumbnailSize();
ThumbnailSize(int size);
ThumbnailSize(const ThumbnailSize& thumbsize);
~ThumbnailSize()
{
}
~ThumbnailSize();
ThumbnailSize& operator=(const ThumbnailSize& thumbsize)
{
m_Size = thumbsize.m_Size;
return *this;
}
ThumbnailSize& operator=(const ThumbnailSize& thumbsize);
bool operator==(const ThumbnailSize& thumbsize) const;
bool operator!=(const ThumbnailSize& thumbsize) const;
bool operator==(const ThumbnailSize& thumbsize) const
{
return m_Size == thumbsize.m_Size;
}
int size() const;
bool operator!=(const ThumbnailSize& thumbsize) const
{
return m_Size != thumbsize.m_Size;
}
public:
int size() const
{
return m_Size;
}
static void setUseLargeThumbs(bool val);
static bool getUseLargeThumbs();
static void readSettings(const KConfigGroup& group);
static void saveSettings(KConfigGroup& group, bool val);
static int maxThumbsSize();
private:
int m_Size;
int m_Size;
};
} // namespace Digikam
......
......@@ -103,7 +103,7 @@ DZoomBar::DZoomBar(QWidget* const parent)
d->zoomSlider = new QSlider(Qt::Horizontal, this);
d->zoomTracker = new DTipTracker(QString(""), d->zoomSlider);
d->zoomSlider->setRange(ThumbnailSize::Small, ThumbnailSize::Huge);
d->zoomSlider->setRange(ThumbnailSize::Small, ThumbnailSize::maxThumbsSize());
d->zoomSlider->setSingleStep(ThumbnailSize::Step);
d->zoomSlider->setValue(ThumbnailSize::Medium);
d->zoomSlider->setFixedWidth(120);
......@@ -243,7 +243,7 @@ void DZoomBar::setThumbsSize(int size)
int DZoomBar::sizeFromZoom(double zoom, double zmin, double zmax)
{
double h = (double)ThumbnailSize::Huge;
double h = (double)ThumbnailSize::maxThumbsSize();
double s = (double)ThumbnailSize::Small;
double zoomN = log(zoom)/log(2);
double zminN = log(zmin)/log(2);
......@@ -254,7 +254,7 @@ int DZoomBar::sizeFromZoom(double zoom, double zmin, double zmax)
double DZoomBar::zoomFromSize(int size, double zmin, double zmax)
{
double h = (double)ThumbnailSize::Huge;
double h = (double)ThumbnailSize::maxThumbsSize();
double s = (double)ThumbnailSize::Small;
double zminN = log(zmin)/log(2);
double zmaxN = log(zmax)/log(2);
......
......@@ -521,7 +521,7 @@ int ImportDelegate::calculatethumbSizeToFit(int ws)
double rs1 = fmod((double)ws, (double)gs);
for (ts1 = ts ; ts1 < ThumbnailSize::Huge ; ++ts1)
for (ts1 = ts ; ts1 < ThumbnailSize::maxThumbsSize() ; ++ts1)
{
ngs = ts1 + 2*(d->margin + d->radius) + sp;
double nrs = fmod((double)ws, (double)ngs);
......@@ -599,7 +599,7 @@ int ImportThumbnailDelegate::maximumSize() const
{
Q_D(const ImportThumbnailDelegate);
return ThumbnailSize::Huge + (2*d->radius + 2*d->margin);
return ThumbnailSize::maxThumbsSize() + (2*d->radius + 2*d->margin);
}
int ImportThumbnailDelegate::minimumSize() const
......
......@@ -302,9 +302,9 @@ void ImportThumbnailModel::startKdePreviewJob()
if (url.isValid())
items.append(KFileItem(KFileItem::Unknown, KFileItem::Unknown, url, true));
}
d->kdeJob = KIO::filePreview(items, QSize(ThumbnailSize::Huge, ThumbnailSize::Huge));
d->kdeJob = KIO::filePreview(items, QSize(ThumbnailSize::maxThumbsSize(), ThumbnailSize::maxThumbsSize()));
#else
d->kdeJob = KIO::filePreview(list, ThumbnailSize::Huge);
d->kdeJob = KIO::filePreview(list, ThumbnailSize::maxThumbsSize());
#endif
connect(d->kdeJob, SIGNAL(gotPreview(KFileItem,QPixmap)),
......@@ -421,7 +421,7 @@ void ImportThumbnailModel::clearCache()
void ImportThumbnailModel::setCacheSize(int numberOfItems)
{
d->cache.setMaxCost((numberOfItems * ThumbnailSize::Huge * ThumbnailSize::Huge * QPixmap::defaultDepth() / 8) +
d->cache.setMaxCost((numberOfItems * ThumbnailSize::maxThumbsSize() * ThumbnailSize::maxThumbsSize() * QPixmap::defaultDepth() / 8) +
(numberOfItems * 1024 * 2));
}
......
......@@ -490,9 +490,9 @@ void ImportView::setThumbSize(int size)
}
else if (d->stackedView->viewMode() == ImportStackedView::PreviewCameraMode)
{
if (size > ThumbnailSize::Huge)
if (size > ThumbnailSize::maxThumbsSize())
{
d->thumbSize = ThumbnailSize::Huge;
d->thumbSize = ThumbnailSize::maxThumbsSize();
}
else if (size < ThumbnailSize::Small)
{
......@@ -544,7 +544,7 @@ void ImportView::toggleZoomActions()
d->parent->enableZoomMinusAction(true);
d->parent->enableZoomPlusAction(true);
if (d->thumbSize >= ThumbnailSize::Huge)
if (d->thumbSize >= ThumbnailSize::maxThumbsSize())
{
d->parent->enableZoomPlusAction(false);
}
......
......@@ -7,7 +7,7 @@
* Description : digiKam setup dialog.
*
* Copyright (C) 2003-2005 by Renchi Raju <renchi dot raju at gmail dot com>
* Copyright (C) 2003-2013 by Gilles Caulier <caulier dot gilles at gmail dot com>
* Copyright (C) 2003-2014 by Gilles Caulier <caulier dot gilles at gmail dot com>
*
* This program is free software; you can redistribute it
* and/or modify it under the terms of the GNU Album
......@@ -547,12 +547,21 @@ void Setup::okClicked()
kapp->restoreOverrideCursor();
if (d->albumViewPage->useLargeThumbsAsChanged())
{
QString msg = i18n("The max thumbnails size has been changed.\n"
"You need to re-start digiKam to see this option to take effect.\n\n"
"Note: after to restart digiKam, it's recommend to rebuild all "
"albums' items' thumbnails, using \"Tools-Maintenance\" menu.");
KMessageBox::information(this, msg);
}
if (d->metadataPage->exifAutoRotateAsChanged())
{
QString msg = i18n("The Exif auto-rotate thumbnails option has been changed.\n"
"Do you want to rebuild all albums' items' thumbnails now?\n\n"
"Note: thumbnail processing can take a while. You can start "
"this job later from the \"Tools\" menu.");
"this job later from the \"Tools-Maintenance\" menu.");
int result = KMessageBox::warningYesNo(this, msg);
if (result != KMessageBox::Yes)
......@@ -746,7 +755,7 @@ KPageWidgetItem* Setup::Private::pageItem(Setup::Page page) const
case Setup::ImageQualityPage:
return page_imagequalitysorter;
case Setup::ICCPage:
return page_icc;
......
......@@ -7,7 +7,7 @@
* Description : digiKam setup dialog.
*
* Copyright (C) 2003-2005 by Renchi Raju <renchi dot raju at gmail dot com>
* Copyright (C) 2003-2013 by Gilles Caulier <caulier dot gilles at gmail dot com>
* Copyright (C) 2003-2014 by Gilles Caulier <caulier dot gilles at gmail dot com>
*
* This program is free software; you can redistribute it
* and/or modify it under the terms of the GNU General
......
......@@ -7,7 +7,7 @@
* Description : album view configuration setup tab
*
* Copyright (C) 2003-2004 by Renchi Raju <renchi dot raju at gmail dot com>
* Copyright (C) 2005-2012 by Gilles Caulier <caulier dot gilles at gmail dot com>
* Copyright (C) 2005-2014 by Gilles Caulier <caulier dot gilles at gmail dot com>
*
* This program is free software; you can redistribute it
* and/or modify it under the terms of the GNU General
......@@ -43,6 +43,7 @@
// Local includes
#include "thumbnailsize.h"
#include "albumsettings.h"
#include "dfontselect.h"
#include "fullscreensettings.h"
......@@ -56,6 +57,8 @@ class SetupAlbumView::Private
public:
Private() :
useLargeThumbsAsChanged(false),
useLargeThumbsOrg(false),
iconTreeThumbLabel(0),
iconShowNameBox(0),
iconShowSizeBox(0),
......@@ -72,6 +75,7 @@ public:
previewLoadFullImageSize(0),
previewShowIcons(0),
showFolderTreeViewItemsCount(0),
largeThumbsBox(0),
iconTreeThumbSize(0),
leftClickActionComboBox(0),
iconViewFontSelect(0),
......@@ -80,6 +84,9 @@ public:
{
}
bool useLargeThumbsAsChanged;
bool useLargeThumbsOrg;
QLabel* iconTreeThumbLabel;
QCheckBox* iconShowNameBox;
......@@ -97,6 +104,7 @@ public:
QCheckBox* previewLoadFullImageSize;
QCheckBox* previewShowIcons;
QCheckBox* showFolderTreeViewItemsCount;
QCheckBox* largeThumbsBox;
KComboBox* iconTreeThumbSize;
KComboBox* leftClickActionComboBox;
......@@ -175,6 +183,14 @@ SetupAlbumView::SetupAlbumView(QWidget* const parent)
d->iconViewFontSelect = new DFontSelect(i18n("Icon View font:"), panel);
d->iconViewFontSelect->setToolTip(i18n("Select here the font used to display text in Icon Views."));
d->largeThumbsBox = new QCheckBox(i18n("Use larges thumbnails size for high screen resolution"), iconViewGroup);
d->largeThumbsBox->setWhatsThis(i18n("Set this option to render icon-view with large thumbnails size, for example in case of 4K screens are used.\n"
"By default this option is turned off and max thumnails size is limited to 256x256 pixels. "
"When this option is enabled, thumbnails size can be extened to 512x512 pixels.\n"
"This option will store more data in thumbnails database and will use more system memory. "
"digiKam need to be restarted to take effect, and Rebuild Thumbnails option from Maintenance tool "
"need to be processed over whole collections."));
grid->addWidget(d->iconShowNameBox, 0, 0, 1, 1);
grid->addWidget(d->iconShowSizeBox, 1, 0, 1, 1);
grid->addWidget(d->iconShowDateBox, 2, 0, 1, 1);
......@@ -192,6 +208,7 @@ SetupAlbumView::SetupAlbumView(QWidget* const parent)
grid->addWidget(leftClickLabel, 7, 0, 1, 1);
grid->addWidget(d->leftClickActionComboBox, 7, 1, 1, 1);
grid->addWidget(d->iconViewFontSelect, 8, 0, 1, 2);
grid->addWidget(d->largeThumbsBox, 9, 0, 1, 2);
grid->setSpacing(KDialog::spacingHint());
grid->setMargin(KDialog::spacingHint());
......@@ -263,6 +280,11 @@ SetupAlbumView::SetupAlbumView(QWidget* const parent)
// --------------------------------------------------------
connect(d->largeThumbsBox, SIGNAL(toggled(bool)),
this, SLOT(slotUseLargeThumbsToggled(bool)));
// --------------------------------------------------------
setAutoFillBackground(false);
viewport()->setAutoFillBackground(false);
panel->setAutoFillBackground(false);
......@@ -275,7 +297,7 @@ SetupAlbumView::~SetupAlbumView()
void SetupAlbumView::applySettings()
{
AlbumSettings* settings = AlbumSettings::instance();
AlbumSettings* const settings = AlbumSettings::instance();
if (!settings)
{
......@@ -308,11 +330,15 @@ void SetupAlbumView::applySettings()
KConfigGroup group = settings->generalConfigGroup();
d->fullScreenSettings->saveSettings(group);
// Method ThumbnailSize::setUseLargeThumbs() is not called here to prevent dysfunction between Thumbs DB and icon if
// thumb size is over 256 and when large thumbs size support is disabled. digiKam need to be restarted to take effect.
ThumbnailSize::saveSettings(group, d->largeThumbsBox->isChecked());
}
void SetupAlbumView::readSettings()
{
AlbumSettings* settings = AlbumSettings::instance();
AlbumSettings* const settings = AlbumSettings::instance();
if (!settings)
{
......@@ -359,6 +385,27 @@ void SetupAlbumView::readSettings()
KConfigGroup group = settings->generalConfigGroup();
d->fullScreenSettings->readSettings(group);
ThumbnailSize::readSettings(group);
d->useLargeThumbsOrg = ThumbnailSize::getUseLargeThumbs();
d->largeThumbsBox->setChecked(d->useLargeThumbsOrg);
}
bool SetupAlbumView::useLargeThumbsAsChanged() const
{
return d->useLargeThumbsAsChanged;
}
void SetupAlbumView::slotUseLargeThumbsToggled(bool b)
{
if (b != d->useLargeThumbsOrg)
{