Commit 7a84fb8f authored by Gilles Caulier's avatar Gilles Caulier 🗼
Browse files

Slideshow now handle Tags keyboard shortcuts, like Labels

There is no GUI way to edit tags without to bloat slide screen. So keyboard shortcuts are best way to change tags while slideshow.
BUGS: 163941
FIXED-IN: 4.4.0
parent 9913c5ce
......@@ -7,7 +7,7 @@ General : Naviguate between pictures using PageUp/PageDown is now possible whi
General : New keyboard shortcuts to improve usability while photo review (as to switch focus on text edit widget, or to toogle tags view).
General : New keyboard shortcut to switch on/off color managed view for thumbnails and preview.
AlbumGUI : Album preview can be displayed in tooltip.
SlideShow : Labels keyboard shortcuts can be used while slideshow.
SlideShow : Labels and Tags keyboard shortcuts can be used while slideshow.
BUGFIXES FROM KDE BUGZILLA (https://www.digikam.org/changelog):
......@@ -45,4 +45,5 @@ BUGFIXES FROM KDE BUGZILLA (https://www.digikam.org/changelog):
032 ==> 312043 - Show image Title in Slideshow.
033 ==> 242119 - Interactive Slideshow (presentation mode).
034 ==> 339051 - Allow the usage of arrows to move in the photo sequence when in slideshow [patch].
035 ==>
035 ==> 163941 - Show and assign Tags while Slideshow.
036 ==>
......@@ -43,6 +43,8 @@
#include "albummanager.h"
#include "databaseaccess.h"
#include "databaseconstants.h"
#include "databasewatch.h"
#include "databaseinfocontainers.h"
#include "digikamapp.h"
#include "dxmlguiwindow.h"
#include "digikamview.h"
......@@ -99,6 +101,9 @@ TagsActionMngr::TagsActionMngr(QWidget* const parent)
connect(AlbumManager::instance(), SIGNAL(signalAlbumDeleted(Album*)),
this, SLOT(slotAlbumDeleted(Album*)));
connect(DatabaseAccess::databaseWatch(), SIGNAL(imageTagChange(ImageTagChangeset)),
this, SLOT(slotImageTagChanged(ImageTagChangeset)));
}
TagsActionMngr::~TagsActionMngr()
......@@ -503,17 +508,28 @@ void TagsActionMngr::slotAssignFromShortcut()
{
sld->slotAssignColorLabel(val);
}
/* TODO : support tags assignment while slideshow
else if (action->objectName().startsWith(d->tagShortcutPrefix))
else if (action->objectName().startsWith(d->tagShortcutPrefix))
{
sld->toggleTag(val);
}
*/
return;
}
}
// Special case with Slideshow which do not depand of database.
void TagsActionMngr::slotImageTagChanged(const ImageTagChangeset& changeset)
{
QWidget* const w = kapp->activeWindow();
SlideShow* const sld = dynamic_cast<SlideShow*>(w);
if (sld)
{
KUrl url = sld->currentUrl();
ImageInfo info(url);
sld->updateTags(url, AlbumManager::instance()->tagNames(info.tagIds()));
}
}
} // namespace Digikam
......@@ -42,6 +42,7 @@ namespace Digikam
{
class Album;
class ImageTagChangeset;
class TagsActionMngr : public QObject
{
......@@ -102,6 +103,8 @@ private Q_SLOTS:
*/
void slotTagActionChanged();
void slotImageTagChanged(const ImageTagChangeset& changeset);
private:
bool createTagActionShortcut(int tagId);
......
......@@ -1987,8 +1987,8 @@ void DigikamView::slotLeftSidebarChangedTab(QWidget* w)
void DigikamView::toggleTag(int tagID)
{
ImageInfoList tagToRemove, tagToAssign;
const ImageInfoList selectedList = selectedInfoList();
foreach(ImageInfo info, selectedList)
{
if (info.tagIds().contains(tagID))
......@@ -1997,8 +1997,8 @@ void DigikamView::toggleTag(int tagID)
tagToAssign.append(info);
}
FileActionMngr::instance()->assignTags(tagToAssign, QList<int>() << tagID);
FileActionMngr::instance()->removeTags(tagToRemove, QList<int>() << tagID);
FileActionMngr::instance()->assignTag(tagToAssign, tagID);
FileActionMngr::instance()->removeTag(tagToRemove, tagID);
}
void DigikamView::slotAssignPickLabel(int pickId)
......@@ -2060,7 +2060,7 @@ void DigikamView::slotSlideShowBuilderComplete(const SlideShowSettings& settings
if (settings.startWithCurrent)
{
slide->setCurrent(currentUrl());
slide->setCurrentUrl(currentUrl());
}
connect(slide, SIGNAL(signalRatingChanged(KUrl,int)),
......@@ -2072,6 +2072,9 @@ void DigikamView::slotSlideShowBuilderComplete(const SlideShowSettings& settings
connect(slide, SIGNAL(signalPickLabelChanged(KUrl,int)),
this, SLOT(slotPickLabelChanged(KUrl,int)));
connect(slide, SIGNAL(signalToggleTag(KUrl,int)),
this, SLOT(slotToggleTag(KUrl,int)));
slide->show();
}
......@@ -2157,11 +2160,7 @@ void DigikamView::slotRatingChanged(const KUrl& url, int rating)
if (!info.isNull())
{
MetadataHub hub;
hub.load(info);
hub.setRating(rating);
hub.write(info, MetadataHub::PartialWrite);
hub.write(info.filePath(), MetadataHub::FullWriteIfChanged);
FileActionMngr::instance()->assignRating(info, rating);
}
}
......@@ -2171,11 +2170,7 @@ void DigikamView::slotColorLabelChanged(const KUrl& url, int color)
if (!info.isNull())
{
MetadataHub hub;
hub.load(info);
hub.setColorLabel(color);
hub.write(info, MetadataHub::PartialWrite);
hub.write(info.filePath(), MetadataHub::FullWriteIfChanged);
FileActionMngr::instance()->assignColorLabel(info, color);
}
}
......@@ -2185,11 +2180,20 @@ void DigikamView::slotPickLabelChanged(const KUrl& url, int pick)
if (!info.isNull())
{
MetadataHub hub;
hub.load(info);
hub.setPickLabel(pick);
hub.write(info, MetadataHub::PartialWrite);
hub.write(info.filePath(), MetadataHub::FullWriteIfChanged);
FileActionMngr::instance()->assignPickLabel(info, pick);
}
}
void DigikamView::slotToggleTag(const KUrl& url, int tagID)
{
ImageInfo info(url);
if (!info.isNull())
{
if (info.tagIds().contains(tagID))
FileActionMngr::instance()->removeTag(info, tagID);
else
FileActionMngr::instance()->assignTag(info, tagID);
}
}
......
......@@ -274,10 +274,11 @@ private Q_SLOTS:
void slotRatingChanged(const KUrl&, int);
void slotColorLabelChanged(const KUrl&, int);
void slotPickLabelChanged(const KUrl&, int);
void slotToggleTag(const KUrl&, int);
void slotPopupFiltersView();
void slotSetupMetadataFilters(int);
void slotAlbumRefreshComplete();
private:
......
......@@ -1068,7 +1068,7 @@ void ShowFoto::slideShow(Digikam::SlideShowSettings& settings)
if (settings.startWithCurrent)
{
slide->setCurrent(d->thumbBar->currentUrl());
slide->setCurrentUrl(d->thumbBar->currentUrl());
}
slide->show();
......
......@@ -817,11 +817,7 @@ void ImageWindow::slotAssignTag(int tagID)
{
if (!d->currentImageInfo.isNull())
{
MetadataHub hub;
hub.load(d->currentImageInfo);
hub.setTag(tagID, true);
hub.write(d->currentImageInfo, MetadataHub::PartialWrite);
hub.write(d->currentImageInfo.filePath(), MetadataHub::FullWriteIfChanged);
FileActionMngr::instance()->assignTag(d->currentImageInfo, tagID);
}
}
......@@ -829,11 +825,7 @@ void ImageWindow::slotRemoveTag(int tagID)
{
if (!d->currentImageInfo.isNull())
{
MetadataHub hub;
hub.load(d->currentImageInfo);
hub.setTag(tagID, false);
hub.write(d->currentImageInfo, MetadataHub::PartialWrite);
hub.write(d->currentImageInfo.filePath(), MetadataHub::FullWriteIfChanged);
FileActionMngr::instance()->removeTag(d->currentImageInfo, tagID);
}
}
......@@ -851,11 +843,7 @@ void ImageWindow::assignPickLabel(const ImageInfo& info, int pickId)
{
if (!info.isNull())
{
MetadataHub hub;
hub.load(info);
hub.setPickLabel(pickId);
hub.write(info, MetadataHub::PartialWrite);
hub.write(info.filePath(), MetadataHub::FullWriteIfChanged);
FileActionMngr::instance()->assignPickLabel(info, pickId);
}
}
......@@ -863,11 +851,7 @@ void ImageWindow::assignColorLabel(const ImageInfo& info, int colorId)
{
if (!info.isNull())
{
MetadataHub hub;
hub.load(info);
hub.setColorLabel(colorId);
hub.write(info, MetadataHub::PartialWrite);
hub.write(info.filePath(), MetadataHub::FullWriteIfChanged);
FileActionMngr::instance()->assignColorLabel(info, colorId);
}
}
......@@ -882,11 +866,7 @@ void ImageWindow::assignRating(const ImageInfo& info, int rating)
if (!info.isNull())
{
MetadataHub hub;
hub.load(info);
hub.setRating(rating);
hub.write(info, MetadataHub::PartialWrite);
hub.write(info.filePath(), MetadataHub::FullWriteIfChanged);
FileActionMngr::instance()->assignRating(info, rating);
}
}
......@@ -1434,7 +1414,7 @@ void ImageWindow::slideShow(SlideShowSettings& settings)
if (settings.startWithCurrent)
{
slide->setCurrent(d->currentUrl());
slide->setCurrentUrl(d->currentUrl());
}
connect(slide, SIGNAL(signalRatingChanged(KUrl,int)),
......
......@@ -346,6 +346,7 @@ void LightTableThumbBar::assignPickLabel(const ImageInfo& info, int pickId)
void LightTableThumbBar::assignRating(const ImageInfo& info, int rating)
{
rating = qMin(RatingMax, qMax(RatingMin, rating));
FileActionMngr::instance()->assignRating(info, rating);
}
......
......@@ -1456,7 +1456,7 @@ void LightTableWindow::slideShow(SlideShowSettings& settings)
if (settings.startWithCurrent)
{
slide->setCurrent(d->thumbView->currentInfo().fileUrl());
slide->setCurrentUrl(d->thumbView->currentInfo().fileUrl());
}
connect(slide, SIGNAL(signalRatingChanged(KUrl,int)),
......
......@@ -55,6 +55,8 @@
#include <klocale.h>
#include <kstandarddirs.h>
#include <kdebug.h>
#include <khbox.h>
#include <ksqueezedtextlabel.h>
// Local includes
......@@ -88,6 +90,7 @@ public:
mouseMoveTimer(0),
timer(0),
labelsBox(0),
tagsWidget(0),
previewThread(0),
previewPreloadThread(0),
toolBar(0),
......@@ -120,6 +123,8 @@ public:
KHBox* labelsBox;
KSqueezedTextLabel* tagsWidget;
PreviewLoadThread* previewThread;
PreviewLoadThread* previewPreloadThread;
......@@ -211,6 +216,16 @@ SlideShow::SlideShow(const SlideShowSettings& settings)
// ---------------------------------------------------------------
d->tagsWidget = new KSqueezedTextLabel(this);
d->tagsWidget->setVisible(false);
d->tagsWidget->setAlignment(Qt::AlignLeft | Qt::AlignTop);
d->tagsWidget->setWordWrap(false);
d->tagsWidget->setTextElideMode(Qt::ElideRight);
d->tagsWidget->setFixedWidth(width()/3);
d->tagsWidget->setTextFormat(Qt::RichText);
// ---------------------------------------------------------------
d->previewThread = new PreviewLoadThread();
d->previewPreloadThread = new PreviewLoadThread();
d->timer = new QTimer(this);
......@@ -218,6 +233,7 @@ SlideShow::SlideShow(const SlideShowSettings& settings)
d->previewThread->setDisplayingWidget(this);
d->previewPreloadThread->setDisplayingWidget(this);
connect(d->previewThread, SIGNAL(signalImageLoaded(LoadingDescription,DImg)),
this, SLOT(slotGotImagePreview(LoadingDescription,DImg)));
......@@ -252,7 +268,7 @@ SlideShow::~SlideShow()
delete d;
}
void SlideShow::setCurrent(const KUrl& url)
void SlideShow::setCurrentUrl(const KUrl& url)
{
int index = d->settings.fileList.indexOf(url);
......@@ -263,6 +279,11 @@ void SlideShow::setCurrent(const KUrl& url)
}
}
KUrl SlideShow::currentUrl() const
{
return d->currentImage;
}
void SlideShow::slotTimeOut()
{
loadNextImage();
......@@ -454,7 +475,21 @@ void SlideShow::updatePixmap()
QString comment = d->settings.pictInfoMap[d->currentImage].comment;
QString title = d->settings.pictInfoMap[d->currentImage].title;
QStringList tags = d->settings.pictInfoMap[d->currentImage].tags;
int offset = d->settings.printLabels ? 30 : 0;
int offset = d->settings.printTags ? 30 : 0;
// Display tag names.
d->tagsWidget->setVisible(d->settings.printTags);
if (d->settings.printTags)
{
d->tagsWidget->move(10, height() - offset - d->tagsWidget->minimumHeight());
printTags(tags);
offset += d->tagsWidget->minimumHeight();
}
// Convert offset to pixmap units
offset = int(ratio*offset);
// Display Labels.
......@@ -462,6 +497,7 @@ void SlideShow::updatePixmap()
int color = d->settings.pictInfoMap[d->currentImage].colorLabel;
int pick = d->settings.pictInfoMap[d->currentImage].pickLabel;
d->labelsBox->setVisible(d->settings.printLabels);
offset += d->settings.printLabels ? 30 : 0;
if (d->settings.printLabels)
{
......@@ -475,20 +511,6 @@ void SlideShow::updatePixmap()
// convert offset to pixmap units
offset = int(ratio*offset);
// Display tag names.
if (d->settings.printTags)
{
str.clear();
if (!tags.isEmpty())
{
tags.sort();
str += tags.join(", ");;
printInfoText(p, offset, str);
}
}
// Display Titles.
if (d->settings.printTitle)
......@@ -698,7 +720,7 @@ void SlideShow::printInfoText(QPainter& p, int& offset, const QString& str)
offset += QFontMetrics(p.font()).lineSpacing();
p.setPen(Qt::black);
for (int x = 19; x <= 21; ++x)
for (int x = 9; x <= 11; ++x)
{
for (int y = offset + 1; y >= offset - 1; --y)
{
......@@ -707,7 +729,7 @@ void SlideShow::printInfoText(QPainter& p, int& offset, const QString& str)
}
p.setPen(Qt::white);
p.drawText(20, p.window().height() - offset, str);
p.drawText(10, p.window().height() - offset, str);
}
}
......@@ -948,6 +970,7 @@ void SlideShow::slotMouseMoveTimeOut()
}
// from Okular's presentation widget
// TODO: Add OSX and Windows support
void SlideShow::inhibitScreenSaver()
{
QDBusMessage message = QDBusMessage::createMethodCall("org.freedesktop.ScreenSaver", "/ScreenSaver",
......@@ -1001,6 +1024,28 @@ void SlideShow::slotAssignPickLabel(int pick)
emit signalPickLabelChanged(d->currentImage, pick);
}
void SlideShow::toggleTag(int tag)
{
emit signalToggleTag(d->currentImage, tag);
}
void SlideShow::updateTags(const KUrl& url, const QStringList& tags)
{
d->settings.pictInfoMap[url].tags = tags;
if (d->currentImage == url)
printTags(d->settings.pictInfoMap[url].tags);
}
void SlideShow::printTags(QStringList& tags)
{
tags.sort();
d->tagsWidget->setText(QString("<qt><font color=%1>%2</font></qt>")
.arg(kapp->palette().color(QPalette::Link).name())
.arg(tags.join(", ")));
}
bool SlideShow::eventFilter(QObject* obj, QEvent* ev)
{
if (obj == d->ratingWidget ||
......
......@@ -52,13 +52,18 @@ public:
explicit SlideShow(const SlideShowSettings& settings);
~SlideShow();
void setCurrent(const KUrl& url);
void setCurrentUrl(const KUrl& url);
KUrl currentUrl() const;
void toggleTag(int tag);
void updateTags(const KUrl& url, const QStringList& tags);
Q_SIGNALS:
void signalRatingChanged(const KUrl&, int);
void signalColorLabelChanged(const KUrl&, int);
void signalPickLabelChanged(const KUrl&, int);
void signalToggleTag(const KUrl&, int);
public Q_SLOTS:
......@@ -95,6 +100,7 @@ private:
void updatePixmap();
void printInfoText(QPainter& p, int& offset, const QString& str);
void printComments(QPainter& p, int& offset, const QString& comments);
void printTags(QStringList& tags);
void inhibitScreenSaver();
void allowScreenSaver();
void makeCornerRectangles(const QRect& desktopRect, const QSize& size,
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment