Commit f4137b33 authored by Jonathan Marten's avatar Jonathan Marten Committed by Stefano Crocco
Browse files

Port and update the Image Gallery plugin

kDebug(), qDebug() -> qCDebug() with logging category
No need to link with KDELibs4Support
Convert layouts to use QFormLayout
KIntNumInput -> QSpinBox
Use Qt5 signal connection syntax
Replace deprecated "What's This" with tool tips
KToolInvocation::invokeBrowser() -> QDesktopServices::openUrl()
KLocale::formatDate() -> QLocale
KImageIO::pattern() -> QImageReader/QMimeDatabase
KIO::NetAccess::file_copy() -> QFile::copy() - files are known to be local
parent 5c8e70cc
########### next target ###############
add_definitions(-DTRANSLATION_DOMAIN=\"imgalleryplugin\")
add_definitions(-DKDE_VERSION_STRING=\"${RELEASE_SERVICE_VERSION}\")
set(kimgallery_PART_SRCS imgalleryplugin.cpp imgallerydialog.cpp )
ecm_qt_declare_logging_category(kimgallery_PART_SRCS HEADER imgallery_debug.h IDENTIFIER IMAGEGALLERY_LOG CATEGORY_NAME org.kde.konqueror.imagegalleryplugin)
add_library(kimgallery MODULE ${kimgallery_PART_SRCS})
target_link_libraries(kimgallery KF5::Parts KF5::KDELibs4Support)
target_link_libraries(kimgallery KF5::Parts)
install(TARGETS kimgallery DESTINATION ${KDE_INSTALL_PLUGINDIR} )
########### install files ###############
install( FILES kimgalleryplugin.rc kimgalleryplugin.desktop DESTINATION ${KDE_INSTALL_DATADIR}/dolphinpart/kpartplugins )
......@@ -18,5 +17,3 @@ install( FILES kimgalleryplugin.rc kimgalleryplugin.desktop DESTINATION ${KDE_
set(kimagegallery_ICONS 16-actions-imagegallery.png 22-actions-imagegallery.png)
ecm_install_icons(ICONS ${kimagegallery_ICONS} DESTINATION ${KDE_INSTALL_ICONDIR} THEME hicolor)
......@@ -20,26 +20,21 @@ Boston, MA 02110-1301, USA.
#include "imgallerydialog.h"
#include <QLabel>
#include <QLayout>
#include <QComboBox>
#include <QCheckBox>
#include <QLineEdit>
#include <QSpinBox>
#include <QVBoxLayout>
#include <QFrame>
#include <QHBoxLayout>
#include <QGridLayout>
#include <QFormLayout>
#include <QFontDatabase>
#include <QSpinBox>
#include <KLocalizedString>
#include <kfontdialog.h>
#include <kiconloader.h>
#include <klineedit.h>
#include <knuminput.h>
#include <klocalizedstring.h>
#include <kcolorbutton.h>
#include <kurlrequester.h>
#include <kconfig.h>
#include <kconfiggroup.h>
#include <kguiitem.h>
#include <kfontchooser.h>
KIGPDialog::KIGPDialog(QWidget *parent, const QString &path)
: KPageDialog(parent)
......@@ -56,7 +51,7 @@ KIGPDialog::KIGPDialog(QWidget *parent, const QString &path)
setupLookPage(path);
setupDirectoryPage(path);
setupThumbnailPage(path);
connect(buttonBox()->button(QDialogButtonBox::RestoreDefaults), SIGNAL(clicked()), this, SLOT(slotDefault()));
connect(buttonBox()->button(QDialogButtonBox::RestoreDefaults), &QAbstractButton::clicked, this, &KIGPDialog::slotDefault);
}
void KIGPDialog::slotDefault()
......@@ -95,94 +90,54 @@ void KIGPDialog::setupLookPage(const QString &path)
addPage(pageItem);
KConfigGroup look = m_config->group("Look");
QVBoxLayout *vlay = new QVBoxLayout(page);
vlay->setContentsMargins(0, 0, 0, 0);
QLabel *label = new QLabel(i18n("&Page title:"), page);
vlay->addWidget(label);
QFormLayout *form = new QFormLayout(page);
m_title = new QLineEdit(i18n("Image Gallery for %1", path), page);
vlay->addWidget(m_title);
label->setBuddy(m_title);
m_imagesPerRow = new KIntNumInput(look.readEntry("ImagesPerRow", 4), page);
m_imagesPerRow->setRange(1, 8, 1);
m_imagesPerRow->setSliderEnabled(true);
m_imagesPerRow->setLabel(i18n("I&mages per row:"));
vlay->addWidget(m_imagesPerRow);
form->addRow(i18n("&Page title:"), m_title);
QGridLayout *grid = new QGridLayout();
grid->setContentsMargins(2, 2, 2, 2);
grid->setSpacing(2);
vlay->addLayout(grid);
m_imagesPerRow = new QSpinBox(page);
m_imagesPerRow->setMinimumWidth(100);
m_imagesPerRow->setRange(1, 8);
m_imagesPerRow->setSingleStep(1);
m_imagesPerRow->setValue(look.readEntry("ImagesPerRow", 4));
//m_imagesPerRow->setSliderEnabled(true);
form->addRow(i18n("I&mages per row:"), m_imagesPerRow);
m_imageName = new QCheckBox(i18n("Show image file &name"), page);
m_imageName->setChecked(look.readEntry("ImageName", true));
grid->addWidget(m_imageName, 0, 0);
form->addRow(QString(), m_imageName);
m_imageSize = new QCheckBox(i18n("Show image file &size"), page);
m_imageSize->setChecked(look.readEntry("ImageSize", false));
grid->addWidget(m_imageSize, 0, 1);
form->addRow(QString(), m_imageSize);
m_imageProperty = new QCheckBox(i18n("Show image &dimensions"), page);
m_imageProperty->setChecked(look.readEntry("ImageProperty", false));
grid->addWidget(m_imageProperty, 1, 0);
QHBoxLayout *hlay11 = new QHBoxLayout();
vlay->addLayout(hlay11);
form->addRow(QString(), m_imageProperty);
m_fontName = new QComboBox(page);
m_fontName->setSizePolicy(QSizePolicy::MinimumExpanding, m_fontName->sizePolicy().verticalPolicy());
QStringList standardFonts;
KFontChooser::getFontList(standardFonts, 0);
m_fontName->addItems(standardFonts);
m_fontName->setItemText(m_fontName->currentIndex(), look.readEntry("FontName", QFontDatabase::systemFont(QFontDatabase::GeneralFont).family()));
label = new QLabel(i18n("Fon&t name:"), page);
label->setBuddy(m_fontName);
hlay11->addWidget(label);
hlay11->addStretch(1);
hlay11->addWidget(m_fontName);
QHBoxLayout *hlay12 = new QHBoxLayout();
vlay->addLayout(hlay12);
form->addRow(i18n("Fon&t name:"), m_fontName);
m_fontSize = new QSpinBox(page);
m_fontSize->setMinimumWidth(100);
m_fontSize->setMinimum(6);
m_fontSize->setMaximum(15);
m_fontSize->setSingleStep(1);
m_fontSize->setValue(look.readEntry("FontSize", 14));
label = new QLabel(i18n("Font si&ze:"), page);
label->setBuddy(m_fontSize);
hlay12->addWidget(label);
hlay12->addStretch(1);
hlay12->addWidget(m_fontSize);
QHBoxLayout *hlay1 = new QHBoxLayout();
vlay->addLayout(hlay1);
form->addRow(i18n("Font si&ze:"), m_fontSize);
m_foregroundColor = new KColorButton(page);
m_foregroundColor->setColor(QColor(look.readEntry("ForegroundColor", "#d0ffd0")));
label = new QLabel(i18n("&Foreground color:"), page);
label->setBuddy(m_foregroundColor);
hlay1->addWidget(label);
hlay1->addStretch(1);
hlay1->addWidget(m_foregroundColor);
QHBoxLayout *hlay2 = new QHBoxLayout();
vlay->addLayout(hlay2);
form->addRow(i18n("&Foreground color:"), m_foregroundColor);
m_backgroundColor = new KColorButton(page);
m_backgroundColor->setColor(QColor(look.readEntry("BackgroundColor", "#333333")));
label = new QLabel(i18n("&Background color:"), page);
hlay2->addWidget(label);
label->setBuddy(m_backgroundColor);
hlay2->addStretch(1);
hlay2->addWidget(m_backgroundColor);
vlay->addStretch(1);
form->addRow(i18n("&Background color:"), m_backgroundColor);
}
void KIGPDialog::setupDirectoryPage(const QString &path)
......@@ -194,96 +149,67 @@ void KIGPDialog::setupDirectoryPage(const QString &path)
addPage(pageItem);
KConfigGroup group = m_config->group("Directory");
QVBoxLayout *dvlay = new QVBoxLayout(page);
dvlay->setContentsMargins(0, 0, 0, 0);
QLabel *label;
label = new QLabel(i18n("&Save to HTML file:"), page);
dvlay->addWidget(label);
QString whatsThis;
whatsThis = i18n("<p>The name of the HTML file this gallery will be saved to.</p>");
label->setWhatsThis(whatsThis);
QFormLayout *form = new QFormLayout(page);
m_imageNameReq = new KUrlRequester(QUrl::fromLocalFile(QString(path + "images.html")), page);
label->setBuddy(m_imageNameReq);
dvlay->addWidget(m_imageNameReq);
connect(m_imageNameReq, SIGNAL(textChanged(QString)),
this, SLOT(imageUrlChanged(QString)));
m_imageNameReq->setWhatsThis(whatsThis);
form->addRow(i18n("&Save to HTML file:"), m_imageNameReq);
connect(m_imageNameReq, &KUrlRequester::textChanged, this, &KIGPDialog::imageUrlChanged);
m_imageNameReq->setToolTip(i18n("<p>The name of the HTML file this gallery will be saved to.</p>"));
const bool recurseSubDir = group.readEntry("RecurseSubDirectories", false);
m_recurseSubDir = new QCheckBox(i18n("&Recurse subfolders"), page);
m_recurseSubDir->setChecked(recurseSubDir);
whatsThis = i18n("<p>Whether subfolders should be included for the "
"image gallery creation or not.</p>");
m_recurseSubDir->setWhatsThis(whatsThis);
m_recurseSubDir->setToolTip(i18n("<p>Whether subfolders should be included for the "
"image gallery creation or not.</p>"));
form->addRow(QString(), m_recurseSubDir);
const int recursionLevel = group.readEntry("RecursionLevel", 0);
m_recursionLevel = new KIntNumInput(recursionLevel, page);
m_recursionLevel->setRange(0, 99, 1);
m_recursionLevel->setSliderEnabled(true);
m_recursionLevel->setLabel(i18n("Rec&ursion depth:"));
if (recursionLevel == 0) {
m_recursionLevel->setSpecialValueText(i18n("Endless"));
}
m_recursionLevel = new QSpinBox(page);
m_recursionLevel->setMinimumWidth(100);
m_recursionLevel->setRange(0, 99);
m_recursionLevel->setSingleStep(1);
m_recursionLevel->setValue(recursionLevel);
//m_recursionLevel->setSliderEnabled(true);
m_recursionLevel->setSpecialValueText(i18n("Endless"));
m_recursionLevel->setEnabled(recurseSubDir);
whatsThis = i18n("<p>You can limit the number of folders the "
"image gallery creator will traverse to by setting an "
"upper bound for the recursion depth.</p>");
m_recursionLevel->setWhatsThis(whatsThis);
connect(m_recurseSubDir, SIGNAL(toggled(bool)),
m_recursionLevel, SLOT(setEnabled(bool)));
m_recursionLevel->setToolTip(i18n("<p>You can limit the number of folders the "
"image gallery creator will traverse to by setting an "
"upper bound for the recursion depth.</p>"));
form->addRow(i18n("Rec&ursion depth:"), m_recursionLevel);
dvlay->addWidget(m_recurseSubDir);
dvlay->addWidget(m_recursionLevel);
connect(m_recurseSubDir, &QAbstractButton::toggled, m_recursionLevel, &QWidget::setEnabled);
m_copyOriginalFiles = new QCheckBox(i18n("Copy or&iginal files"), page);
m_copyOriginalFiles->setChecked(group.readEntry("CopyOriginalFiles", false));
dvlay->addWidget(m_copyOriginalFiles);
whatsThis = i18n("<p>This makes a copy of all images and the gallery will refer "
"to these copies instead of the original images.</p>");
m_copyOriginalFiles->setWhatsThis(whatsThis);
m_copyOriginalFiles->setToolTip(i18n("<p>This makes a copy of all images and the gallery will refer "
"to these copies instead of the original images.</p>"));
form->addRow(QString(), m_copyOriginalFiles);
const bool useCommentFile = group.readEntry("UseCommentFile", false);
m_useCommentFile = new QCheckBox(i18n("Use &comment file"), page);
m_useCommentFile->setChecked(useCommentFile);
dvlay->addWidget(m_useCommentFile);
whatsThis = i18n("<p>If you enable this option you can specify "
"a comment file which will be used for generating "
"subtitles for the images.</p>"
"<p>For details about the file format please see "
"the \"What's This?\" help below.</p>");
m_useCommentFile->setWhatsThis(whatsThis);
label = new QLabel(i18n("Comments &file:"), page);
label->setEnabled(useCommentFile);
dvlay->addWidget(label);
whatsThis = i18n("<p>You can specify the name of the comment file here. "
"The comment file contains the subtitles for the images. "
"The format of this file is:</p>"
"<p>FILENAME1:"
"<br />Description"
"<br />"
"<br />FILENAME2:"
"<br />Description"
"<br />"
"<br />and so on</p>");
label->setWhatsThis(whatsThis);
m_useCommentFile->setToolTip(i18n("<p>If you enable this option you can specify "
"a comment file which will be used for generating "
"subtitles for the images.</p>"
"<p>For details about the file format please see "
"the \"What's This?\" help below.</p>"));
form->addRow(QString(), m_useCommentFile);
m_commentFileReq = new KUrlRequester(QUrl::fromLocalFile(QString(path + "comments")), page);
m_commentFileReq->setEnabled(useCommentFile);
label->setBuddy(m_commentFileReq);
dvlay->addWidget(m_commentFileReq);
m_commentFileReq->setWhatsThis(whatsThis);
connect(m_useCommentFile, SIGNAL(toggled(bool)),
label, SLOT(setEnabled(bool)));
connect(m_useCommentFile, SIGNAL(toggled(bool)),
m_commentFileReq, SLOT(setEnabled(bool)));
dvlay->addStretch(1);
m_commentFileReq->setToolTip(i18n("<p>You can specify the name of the comment file here. "
"The comment file contains the subtitles for the images. "
"The format of this file is:</p>"
"<p>FILENAME1:"
"<br />Description"
"<br />"
"<br />FILENAME2:"
"<br />Description"
"<br />"
"<br />and so on</p>"));
form->addRow(i18n("Comments &file:"), m_commentFileReq);
connect(m_useCommentFile, &QAbstractButton::toggled, m_commentFileReq, &QWidget::setEnabled);
}
void KIGPDialog::setupThumbnailPage(const QString &path)
......@@ -297,57 +223,39 @@ void KIGPDialog::setupThumbnailPage(const QString &path)
addPage(pageItem);
KConfigGroup group = m_config->group("Thumbnails");
QLabel *label;
QVBoxLayout *vlay = new QVBoxLayout(page);
vlay->setContentsMargins(0, 0, 0, 0);
QHBoxLayout *hlay3 = new QHBoxLayout();
vlay->addLayout(hlay3);
QFormLayout *form = new QFormLayout(page);
m_imageFormat = new QComboBox(page);
m_imageFormat->setSizePolicy(QSizePolicy::MinimumExpanding, m_imageFormat->sizePolicy().verticalPolicy());
QStringList lstImgageFormat;
lstImgageFormat << QStringLiteral("JPEG") << QStringLiteral("PNG");
m_imageFormat->addItems(lstImgageFormat);
m_imageFormat->setItemText(m_imageFormat->currentIndex(), group.readEntry("ImageFormat", "JPEG"));
form->addRow(i18n("Image f&ormat:"), m_imageFormat);
m_thumbnailSize = new QSpinBox(page);
m_thumbnailSize->setMinimumWidth(100);
m_thumbnailSize->setRange(10, 1000);
m_thumbnailSize->setSingleStep(1);
m_thumbnailSize->setValue(group.readEntry("ThumbnailSize", 140));
//m_thumbnailSize->setSliderEnabled(true);
form->addRow(i18n("Thumbnail size:"), m_thumbnailSize);
label = new QLabel(i18n("Image format f&or the thumbnails:"), page);
hlay3->addWidget(label);
label->setBuddy(m_imageFormat);
hlay3->addStretch(1);
hlay3->addWidget(m_imageFormat);
m_thumbnailSize = new KIntNumInput(group.readEntry("ThumbnailSize", 140), page);
m_thumbnailSize->setRange(10, 1000, 1);
m_thumbnailSize->setLabel(i18n("Thumbnail size:"));
m_thumbnailSize->setSliderEnabled(true);
vlay->addWidget(m_thumbnailSize);
QGridLayout *grid = new QGridLayout();
grid->setContentsMargins(2, 2, 2, 2);
grid->setSpacing(2);
vlay->addLayout(grid);
QHBoxLayout *hlay4 = new QHBoxLayout();
vlay->addLayout(hlay4);
const bool colorDepthSet = group.readEntry("ColorDepthSet", false);
m_colorDepthSet = new QCheckBox(i18n("&Set different color depth:"), page);
m_colorDepthSet->setChecked(colorDepthSet);
hlay4->addWidget(m_colorDepthSet);
form->addRow(QString(), m_colorDepthSet);
m_colorDepth = new QComboBox(page);
m_colorDepth->setSizePolicy(QSizePolicy::MinimumExpanding, m_colorDepth->sizePolicy().verticalPolicy());
QStringList lst;
lst << QStringLiteral("1") << QStringLiteral("8") << QStringLiteral("16") << QStringLiteral("32");
m_colorDepth->addItems(lst);
m_colorDepth->setItemText(m_colorDepth->currentIndex(), group.readEntry("ColorDepth", "8"));
m_colorDepth->setCurrentIndex(m_colorDepth->findText(group.readEntry("ColorDepth", "8")));
m_colorDepth->setEnabled(colorDepthSet);
hlay4->addWidget(m_colorDepth);
connect(m_colorDepthSet, SIGNAL(toggled(bool)),
m_colorDepth, SLOT(setEnabled(bool)));
vlay->addStretch(1);
form->addRow(i18n("Color depth:"), m_colorDepth);
connect(m_colorDepthSet, &QAbstractButton::toggled, m_colorDepth, &QWidget::setEnabled);
}
void KIGPDialog::writeConfig()
......
......@@ -23,7 +23,7 @@
#include <kpagedialog.h>
class KIntNumInput;
class QSpinBox;
class QCheckBox;
class QLineEdit;
class KUrlRequester;
......@@ -79,9 +79,9 @@ private:
QLineEdit *m_title;
QString m_path;
KIntNumInput *m_imagesPerRow;
KIntNumInput *m_thumbnailSize;
KIntNumInput *m_recursionLevel;
QSpinBox *m_imagesPerRow;
QSpinBox *m_thumbnailSize;
QSpinBox *m_recursionLevel;
QSpinBox *m_fontSize;
QCheckBox *m_copyOriginalFiles;
......
......@@ -28,28 +28,22 @@ Boston, MA 02110-1301, USA.
#include <QImage>
#include <QTextCodec>
#include <QApplication>
#include <QDesktopServices>
#include <QImageReader>
#include <QMimeDatabase>
#include <QMimeType>
#include <QPushButton>
#include <QProgressDialog>
#include <kglobal.h>
#include <KLocalizedString>
#include <kcharsets.h>
#include <klocalizedstring.h>
#include <kmessagebox.h>
#include <kimageio.h>
#include <kdebug.h>
#include <kpluginfactory.h>
#include <kio/netaccess.h>
#include <QPushButton>
#include <ktoolinvocation.h>
#include <QProgressDialog>
#include <qtextdocument.h>
#include <kactioncollection.h>
#include <kparts/part.h>
#include "imgallerydialog.h"
//KDELibs4Support
#include <kdeversion.h>
#include "imgallery_debug.h"
K_PLUGIN_FACTORY(KImGalleryPluginFactory, registerPlugin<KImGalleryPlugin>();)
......@@ -64,7 +58,7 @@ KImGalleryPlugin::KImGalleryPlugin(QObject *parent, const QVariantList &)
a->setText(i18n("&Create Image Gallery..."));
a->setIcon(QIcon::fromTheme(QStringLiteral("imagegallery")));
actionCollection()->setDefaultShortcut(a, QKeySequence(Qt::CTRL + Qt::Key_I));
connect(a, SIGNAL(triggered()), this, SLOT(slotExecute()));
connect(a, &QAction::triggered, this, &KImGalleryPlugin::slotExecute);
}
void KImGalleryPlugin::slotExecute()
......@@ -85,7 +79,7 @@ void KImGalleryPlugin::slotExecute()
m_configDlg = new KIGPDialog(m_part->widget(), path);
if (m_configDlg->exec() == QDialog::Accepted) {
kDebug(90170) << "dialog is ok";
qCDebug(IMAGEGALLERY_LOG) << "dialog is ok";
m_configDlg->writeConfig();
m_copyFiles = m_configDlg->copyOriginalFiles();
m_recurseSubDirectories = m_configDlg->recurseSubDirectories();
......@@ -95,7 +89,7 @@ void KImGalleryPlugin::slotExecute()
QUrl url(m_configDlg->getImageUrl());
if (!url.isEmpty() && url.isValid()) {
m_progressDlg = new QProgressDialog(m_part->widget());
QObject::connect(m_progressDlg, SIGNAL(canceled()), this, SLOT(slotCancelled()));
connect(m_progressDlg, &QProgressDialog::canceled, this, &KImGalleryPlugin::slotCancelled);
m_progressDlg->setLabelText(i18n("Creating thumbnails"));
QPushButton *button = new QPushButton(m_progressDlg);
......@@ -104,7 +98,7 @@ void KImGalleryPlugin::slotExecute()
m_cancelled = false;
m_progressDlg->show();
if (createHtml(url, m_part->url().path(), m_configDlg->recursionLevel() > 0 ? m_configDlg->recursionLevel() + 1 : 0, m_configDlg->getImageFormat())) {
KToolInvocation::invokeBrowser(url.url()); // Open a browser to show the result
QDesktopServices::openUrl(url); // Open a browser to show the result
} else {
deleteCancelledGallery(url, m_part->url().path(), m_configDlg->recursionLevel() > 0 ? m_configDlg->recursionLevel() + 1 : 0, m_configDlg->getImageFormat());
}
......@@ -179,7 +173,7 @@ void KImGalleryPlugin::createBody(QTextStream &stream, const QString &sourceDirN
{
int numOfImages = imageDir.count();
const QString imgGalleryDir = directory(url);
const QString today(KLocale::global()->formatDate(QDate::currentDate()));
const QString today(QLocale().toString(QDate::currentDate()));
stream << "<body>\n<h1>" << m_configDlg->getTitle().toHtmlEscaped() << "</h1><p>" << endl;
stream << i18n("<i>Number of images</i>: %1", numOfImages) << "<br/>" << endl;
......@@ -223,7 +217,7 @@ void KImGalleryPlugin::createBody(QTextStream &stream, const QString &sourceDirN
stream << "height=\"" << m_imgHeight << "\" alt=\"" << imgPath << "\"/>";
m_progressDlg->setLabelText(i18n("Created thumbnail for: \n%1", imgName));
} else {
kDebug(90170) << "Creating thumbnail for " << imgName << " failed";
qCDebug(IMAGEGALLERY_LOG) << "Creating thumbnail for " << imgName << " failed";
m_progressDlg->setLabelText(i18n("Creating thumbnail for: \n%1\n failed", imgName));
}
stream << "</a>" << endl;
......@@ -233,9 +227,6 @@ void KImGalleryPlugin::createBody(QTextStream &stream, const QString &sourceDirN
}
if (m_configDlg->printImageProperty()) {
#ifdef __GNUC__
#warning "kde4: verify it : imageDir.absoluteFilePath(imgName,true)";
#endif
imgProp.load(imageDir.absoluteFilePath(imgName));
stream << "<div>" << imgProp.width() << " x " << imgProp.height() << "</div>" << endl;
}
......@@ -304,16 +295,23 @@ bool KImGalleryPlugin::createHtml(const QUrl &url, const QString &sourceDirName,
loadCommentFile();
}
kDebug(90170) << "sourceDirName: " << sourceDirName;
//We're interested in only the patterns, so look for the first |
//#### perhaps an accessor should be added to KImageIO instead?
QString filter = KImageIO::pattern(KImageIO::Reading).section('|', 0, 0);
qCDebug(IMAGEGALLERY_LOG) << "sourceDirName: " << sourceDirName;
QMimeDatabase db;
QStringList imageNameFilters;
const QList<QByteArray> &mimeNames = QImageReader::supportedMimeTypes();
for (const QByteArray &mimeName : mimeNames)
{
const QMimeType mimeType = db.mimeTypeForName(mimeName);
imageNameFilters.append(mimeType.globPatterns());
}
QDir imageDir(sourceDirName, filter.toLatin1(),
QDir imageDir(sourceDirName, QString(),
QDir::Name | QDir::IgnoreCase, QDir::Files | QDir::Readable);
imageDir.setNameFilters(imageNameFilters);
const QString imgGalleryDir = directory(url);
kDebug(90170) << "imgGalleryDir: " << imgGalleryDir;
qCDebug(IMAGEGALLERY_LOG) << "imgGalleryDir: " << imgGalleryDir;
// Create the "thumbs" subdirectory if necessary
QDir thumb_dir(imgGalleryDir + QLatin1String("/thumbs/"));
......@@ -330,7 +328,7 @@ bool KImGalleryPlugin::createHtml(const QUrl &url, const QString &sourceDirName,
}
QFile file(url.path());
kDebug(90170) << "url.path(): " << url.path() << ", thumb_dir: " << thumb_dir.path()
qCDebug(IMAGEGALLERY_LOG) << "url.path(): " << url.path() << ", thumb_dir: " << thumb_dir.path()
<< ", imageDir: " << imageDir.path() << endl;
if (imageDir.exists() && file.open(QIODevice::WriteOnly)) {
......@@ -386,7 +384,7 @@ void KImGalleryPlugin::deleteCancelledGallery(const QUrl &url, const QString &so
const QString imgName = imageDir[i];
const QString imgNameFormat = imgName + extension(imageFormat);
bool isRemoved = thumb_dir.remove(imgNameFormat);
kDebug(90170) << "removing: " << thumb_dir.path() << "/" << imgNameFormat << "; " << isRemoved;
qCDebug(IMAGEGALLERY_LOG) << "removing: " << thumb_dir.path() << "/" << imgNameFormat << "; " << isRemoved;
}
// ..and the thumb directory
thumb_dir.rmdir(thumb_dir.path());
......@@ -396,7 +394,7 @@ void KImGalleryPlugin::deleteCancelledGallery(const QUrl &url, const QString &so
for (uint i = 0; i < imageDir.count(); i++) {
const QString imgName = imageDir[i];
bool isRemoved = images_dir.remove(imgName);
kDebug(90170) << "removing: " << images_dir.path() << "/" << imgName << "; " << isRemoved;
qCDebug(IMAGEGALLERY_LOG) << "removing: " << images_dir.path() << "/" << imgName << "; " << isRemoved;
}
images_dir.rmdir(images_dir.path());
}
......@@ -406,7 +404,7 @@ void KImGalleryPlugin::loadCommentFile()
{
QFile file(m_configDlg->getCommentFile());
if (file.open(QIODevice::ReadOnly)) {
kDebug(90170) << "File opened.";
qCDebug(IMAGEGALLERY_LOG) << "File opened.";
QTextStream *m_textStream = new QTextStream(&file);
m_textStream->setCodec(QTextCodec::codecForLocale());
......@@ -423,25 +421,25 @@ void KImGalleryPlugin::loadCommentFile()
if (curLineStripped.endsWith(QLatin1String(":"))) {
picComment.clear();
picName = curLineStripped.left(curLineStripped.length() - 1);
kDebug(90170) << "picName: " << picName;
qCDebug(IMAGEGALLERY_LOG) << "picName: " << picName;
} else {
do {
//kDebug(90170) << "picComment";
//qCDebug(IMAGEGALLERY_LOG) << "picComment";
picComment += curLine + '\n';
curLine = m_textStream->readLine();
} while (!m_textStream->atEnd() && !(curLine.trimmed().isEmpty()) &&
!curLine.trimmed().startsWith(QLatin1String("#")));