SVN commit 809790 by cgilles:
digiKam from trunk : enable fuzzy search view based on a drawing sketch. Not yet suitable. MOCUP: http://digikam3rdparty.free.fr/Screenshots/temp/sketchfuzzysearch.png CCMAIL: [hidden email] CCMAIL: [hidden email] M +5 -0 digikamview.cpp M +82 -2 fuzzysearchview.cpp M +8 -3 fuzzysearchview.h M +8 -2 sketchwidget.cpp M +9 -4 sketchwidget.h --- trunk/extragear/graphics/digikam/digikam/digikamview.cpp #809789:809790 @@ -78,6 +78,7 @@ #include "imagepreviewview.h" #include "datefolderview.h" #include "tagfolderview.h" +#include "fuzzysearchview.h" #include "searchfolderview.h" #include "searchtabheader.h" #include "statusprogressbar.h" @@ -124,6 +125,7 @@ albumWidgetStack = 0; selectionTimer = 0; thumbSizeTimer = 0; + fuzzySearchView = 0; needDispatchSelection = false; cancelSlideShow = false; thumbSize = ThumbnailSize::Medium; @@ -167,6 +169,7 @@ SearchFolderView *searchFolderView; SearchTabHeader *searchTabHeader; TagFilterView *tagFilterView; + FuzzySearchView *fuzzySearchView; }; DigikamView::DigikamView(QWidget *parent) @@ -222,12 +225,14 @@ d->dateFolderView = new DateFolderView(this); d->timeLineView = new TimeLineView(this); + d->fuzzySearchView = new FuzzySearchView(this); d->leftSideBar->appendTab(d->folderBox, SmallIcon("folder-image"), i18n("Albums")); d->leftSideBar->appendTab(d->dateFolderView, SmallIcon("view-calendar-list"), i18n("Calendar")); d->leftSideBar->appendTab(d->tagBox, SmallIcon("tag"), i18n("Tags")); d->leftSideBar->appendTab(d->timeLineView, SmallIcon("clock"), i18n("Timeline")); d->leftSideBar->appendTab(d->searchBox, SmallIcon("edit-find"), i18n("Searches")); + d->leftSideBar->appendTab(d->fuzzySearchView, SmallIcon("tools-wizard"), i18n("Fuzzy Searches")); // To the right. --- trunk/extragear/graphics/digikam/digikam/fuzzysearchview.cpp #809789:809790 @@ -37,6 +37,9 @@ #include <kapplication.h> #include <kstandarddirs.h> #include <kmessagebox.h> +#include <khuesaturationselect.h> +#include <kcolorvalueselector.h> +#include <knuminput.h> // Local includes. @@ -58,9 +61,21 @@ FuzzySearchViewPriv() { sketchWidget = 0; + hsSelector = 0; + vSelector = 0; + penSize = 0; + clearButton = 0; } - SketchWidget *sketchWidget; + QPushButton *clearButton; + + KIntNumInput *penSize; + + KHueSaturationSelector *hsSelector; + + KColorValueSelector *vSelector; + + SketchWidget *sketchWidget; }; FuzzySearchView::FuzzySearchView(QWidget *parent) @@ -76,13 +91,52 @@ // --------------------------------------------------------------- d->sketchWidget = new SketchWidget(this); + d->hsSelector = new KHueSaturationSelector(this); + d->vSelector = new KColorValueSelector(this); + d->hsSelector->setMinimumSize(200, 142); + d->vSelector->setMinimumSize(26, 142); // --------------------------------------------------------------- + d->penSize = new KIntNumInput(this); + d->penSize->setRange(1, 40, 1); + d->penSize->setSliderEnabled(true); + d->penSize->setValue(10); + d->penSize->setWhatsThis(i18n("<p>Set here the brush size in pixels used to draw sketch.")); + + // --------------------------------------------------------------- + + d->clearButton = new QPushButton(i18n("Clear"), this); + d->clearButton->setWhatsThis(i18n("<p>Use this button to clear sketch contents.")); + + // --------------------------------------------------------------- + grid->addWidget(d->sketchWidget, 0, 0, 1, 2); - grid->setRowStretch(1, 10); + grid->addWidget(d->hsSelector, 1, 0, 1, 1); + grid->addWidget(d->vSelector, 1, 1, 1, 1); + grid->addWidget(d->penSize, 2, 0, 1, 2); + grid->addWidget(d->clearButton, 3, 0, 1, 2); + grid->setRowStretch(4, 10); + grid->setColumnStretch(0, 10); grid->setMargin(KDialog::spacingHint()); grid->setSpacing(KDialog::spacingHint()); + + // --------------------------------------------------------------- + + connect(d->hsSelector, SIGNAL(valueChanged(int, int)), + this, SLOT(slotHSChanged(int, int))); + + connect(d->vSelector, SIGNAL(valueChanged(int)), + this, SLOT(slotVChanged())); + + connect(d->penSize, SIGNAL(valueChanged(int)), + d->sketchWidget, SLOT(setPenWidth(int))); + + connect(d->clearButton, SIGNAL(clicked()), + d->sketchWidget, SLOT(slotClear())); + + connect(d->sketchWidget, SIGNAL(signalSketchChanged(const QImage&)), + this, SLOT(slotSketchChanged(const QImage&))); } FuzzySearchView::~FuzzySearchView() @@ -91,6 +145,32 @@ delete d; } +void FuzzySearchView::slotHSChanged(int h, int s) +{ + d->vSelector->blockSignals(true); + d->vSelector->setHue(h); + d->vSelector->setSaturation(s); + d->vSelector->updateContents(); + d->vSelector->repaint(); + d->vSelector->blockSignals(false); + slotVChanged(); +} + +void FuzzySearchView::slotVChanged() +{ + int hue = d->hsSelector->xValue(); + int sat = d->hsSelector->yValue(); + int val = d->vSelector->value(); + QColor color = QColor::fromHsv(hue, sat, val); + + d->sketchWidget->setPenColor(color); +} + +void FuzzySearchView::slotSketchChanged(const QImage& /*img*/) +{ + // TODO: query database here ! +} + void FuzzySearchView::readConfig() { /* KSharedConfig::Ptr config = KGlobal::config(); --- trunk/extragear/graphics/digikam/digikam/fuzzysearchview.h #809789:809790 @@ -26,9 +26,8 @@ // Qt includes. -#include <QDateTime> #include <QFrame> -#include <QString> +#include <QImage> namespace Digikam { @@ -51,9 +50,15 @@ void readConfig(); void writeConfig(); +private slots: + + void slotHSChanged(int h, int s); + void slotVChanged(); + void slotSketchChanged(const QImage&); + private: - FuzzySearchViewPriv* d; + FuzzySearchViewPriv *d; }; } // NameSpace Digikam --- trunk/extragear/graphics/digikam/digikam/sketchwidget.cpp #809789:809790 @@ -66,7 +66,7 @@ setAttribute(Qt::WA_StaticContents); setFixedSize(256, 256); - clearSketch(); + slotClear(); } SketchWidget::~SketchWidget() @@ -84,6 +84,11 @@ return d->penWidth; } +QImage SketchWidget::sketchImage() const +{ + return d->pixmap.toImage(); +} + void SketchWidget::setPenColor(const QColor &newColor) { d->penColor = newColor; @@ -94,7 +99,7 @@ d->penWidth = newWidth; } -void SketchWidget::clearSketch() +void SketchWidget::slotClear() { d->pixmap.fill(qRgb(255, 255, 255)); update(); @@ -121,6 +126,7 @@ { drawLineTo(event->pos()); d->drawing = false; + emit signalSketchChanged(sketchImage()); } } --- trunk/extragear/graphics/digikam/digikam/sketchwidget.h #809789:809790 @@ -42,15 +42,20 @@ SketchWidget(QWidget *parent=0); ~SketchWidget(); - void setPenColor(const QColor& newColor); QColor penColor() const; - - void setPenWidth(int newWidth); int penWidth() const; + QImage sketchImage() const; + +signals: + + void signalSketchChanged(const QImage&); + public slots: - void clearSketch(); + void setPenColor(const QColor& newColor); + void setPenWidth(int newWidth); + void slotClear(); protected: _______________________________________________ Digikam-devel mailing list [hidden email] https://mail.kde.org/mailman/listinfo/digikam-devel |
Free forum by Nabble | Edit this page |