SVN commit 629110 by cgilles:
digiKam from trunk : add missing Assign Rating into image editor pop-up menu (like Album Icon View pop-up menu). Marcel : TODO : MetadataHub call at identified right place to assign/remove Tags and assign Rating methods. CCMAIL: [hidden email], [hidden email] M +91 -12 imagewindow.cpp M +10 -9 imagewindow.h --- trunk/extragear/graphics/digikam/utilities/imageeditor/editor/imagewindow.cpp #629109:629110 @@ -1,11 +1,11 @@ /* ============================================================ - * Author: Renchi Raju <[hidden email]> + * Authors: Renchi Raju <[hidden email]> * Gilles Caulier <caulier dot gilles at kdemail dot net> - * Date : 2004-02-12 + * Date : 2004-02-12 * Description : digiKam image editor GUI * * Copyright 2004-2005 by Renchi Raju, Gilles Caulier - * Copyright 2006 by Gilles Caulier + * Copyright 2006-2007 by Gilles Caulier * * This program is free software; you can redistribute it * and/or modify it under the terms of the GNU General @@ -31,6 +31,8 @@ #include <qlabel.h> #include <qimage.h> #include <qsplitter.h> +#include <qpainter.h> +#include <qpixmap.h> // KDE includes. @@ -119,6 +121,8 @@ // image cannot be saved. bool allowSaving; + QPixmap ratingPixmap; + KURL::List urlList; KURL urlCurrent; @@ -164,6 +168,21 @@ d = new ImageWindowPriv; m_instance = this; + // -- Load rating Pixmap ------------------------------------------ + + KGlobal::dirs()->addResourceType("digikam_rating", + KGlobal::dirs()->kde_default("data") + + "digikam/data"); + QString ratingPixPath = KGlobal::dirs()->findResourceDir("digikam_rating", + "rating.png"); + ratingPixPath += "/rating.png"; + d->ratingPixmap = QPixmap(ratingPixPath); + + QPainter painter(&d->ratingPixmap); + painter.fillRect(0, 0, d->ratingPixmap.width(), d->ratingPixmap.height(), + ThemeEngine::instance()->textSpecialRegColor()); + painter.end(); + // -- Build the GUI ------------------------------- setupUserArea(); @@ -535,12 +554,16 @@ { if (d->contextMenu) { - TagsPopupMenu* assignTagsMenu = 0; - TagsPopupMenu* removeTagsMenu = 0; - int separatorID = -1; + QPopupMenu *ratingMenu = 0; + TagsPopupMenu *assignTagsMenu = 0; + TagsPopupMenu *removeTagsMenu = 0; + int separatorID1 = -1; + int separatorID2 = -1; if (d->imageInfoCurrent) { + // Bulk assignment/removal of tags -------------------------- + Q_LLONG id = d->imageInfoCurrent->id(); QValueList<Q_LLONG> idList; idList.append(id); @@ -548,7 +571,7 @@ assignTagsMenu = new TagsPopupMenu(idList, 1000, TagsPopupMenu::ASSIGN); removeTagsMenu = new TagsPopupMenu(idList, 2000, TagsPopupMenu::REMOVE); - separatorID = d->contextMenu->insertSeparator(); + separatorID1 = d->contextMenu->insertSeparator(); d->contextMenu->insertItem(i18n("Assign Tag"), assignTagsMenu); int i = d->contextMenu->insertItem(i18n("Remove Tag"), removeTagsMenu); @@ -561,18 +584,46 @@ AlbumDB* db = AlbumManager::instance()->albumDB(); if (!db->hasTags( idList )) - d->contextMenu->setItemEnabled(i,false); + d->contextMenu->setItemEnabled(i, false); + + separatorID2 = d->contextMenu->insertSeparator(); + + // Assign Star Rating ------------------------------------------- + + ratingMenu = new QPopupMenu(); + + connect(ratingMenu, SIGNAL(activated(int)), + this, SLOT(slotAssignRating(int))); + + ratingMenu->insertItem(i18n("None"), 0); + + for (int i = 1 ; i <= 5 ; i++) + { + QPixmap pix(d->ratingPixmap.width() * 5, d->ratingPixmap.height()); + pix.fill(ratingMenu->colorGroup().background()); + + QPainter painter(&pix); + painter.drawTiledPixmap(0, 0, + i*d->ratingPixmap.width(), + pix.height(), + d->ratingPixmap); + painter.end(); + ratingMenu->insertItem(pix, i); + } + + d->contextMenu->insertItem(i18n("Assign Rating"), ratingMenu); } d->contextMenu->exec(QCursor::pos()); - if (separatorID != -1) - { - d->contextMenu->removeItem(separatorID); - } + if (separatorID1 != -1) + d->contextMenu->removeItem(separatorID1); + if (separatorID2 != -1) + d->contextMenu->removeItem(separatorID2); delete assignTagsMenu; delete removeTagsMenu; + delete ratingMenu; } } @@ -630,6 +681,8 @@ d->imageInfoCurrent->setTag(tagID); + // TODO MetadataHub: fix this part to use it instead. + // Update Image Tags like Iptc keywords tags. if (AlbumSettings::instance()) @@ -652,6 +705,8 @@ d->imageInfoCurrent->removeTag(tagID); + // TODO MetadataHub: fix this part to use it instead. + // Update Image Tags like Iptc keywords tags. if (AlbumSettings::instance()) @@ -666,6 +721,30 @@ } } +void ImageWindow::slotAssignRating(int rating) +{ + rating = QMIN(5, QMAX(0, rating)); + + if (d->imageInfoCurrent) + { + d->imageInfoCurrent->setRating(rating); + + // TODO MetadataHub: fix this part to use it instead. + + // Store Image rating as Iptc tag. + + if (AlbumSettings::instance()) + { + if (AlbumSettings::instance()->getSaveIptcRating()) + { + DMetadata metadata(d->imageInfoCurrent->filePath()); + metadata.setImageRating(rating); + metadata.applyChanges(); + } + } + } +} + void ImageWindow::slotUpdateItemInfo() { uint index = d->urlList.findIndex(d->urlCurrent); --- trunk/extragear/graphics/digikam/utilities/imageeditor/editor/imagewindow.h #629109:629110 @@ -1,11 +1,11 @@ /* ============================================================ - * Author: Renchi Raju <[hidden email]> + * Authors: Renchi Raju <[hidden email]> * Gilles Caulier <caulier dot gilles at kdemail dot net> - * Date : 2004-02-12 + * Date : 2004-02-12 * Description : digiKam image editor GUI * * Copyright 2004-2005 by Renchi Raju, Gilles Caulier - * Copyright 2006 by Gilles Caulier + * Copyright 2006-2007 by Gilles Caulier * * This program is free software; you can redistribute it * and/or modify it under the terms of the GNU General @@ -75,12 +75,6 @@ private: - ImageWindowPriv *d; - - static ImageWindow *m_instance; - -private: - void loadCurrentList(const QString& caption, bool allowSaving); void closeEvent(QCloseEvent* e); @@ -122,10 +116,17 @@ void slotAssignTag(int tagID); void slotRemoveTag(int tagID); + void slotAssignRating(int rating); void slotFileMetadataChanged(const KURL &url); void slotThemeChanged(); + +private: + + ImageWindowPriv *d; + + static ImageWindow *m_instance; }; } // namespace Digikam _______________________________________________ Digikam-devel mailing list [hidden email] https://mail.kde.org/mailman/listinfo/digikam-devel |
Free forum by Nabble | Edit this page |