[Digikam-devel] [Bug 140131] No zoom in image preview

Gilles Caulier caulier.gilles at gmail.com
Sun Apr 8 19:03:43 BST 2007


------- You are receiving this mail because: -------
You are the assignee for the bug, or are watching the assignee.
         
http://bugs.kde.org/show_bug.cgi?id=140131         




------- Additional Comments From caulier.gilles gmail com  2007-04-08 20:03 -------
SVN commit 651639 by cgilles:

digiKam from trunk : Image preview mode is abble to use the slider on status bar to zoom in/out into image.

Zoom factor is given as feedback on slider tool tip.

CCBUGS: 140131

 M  +10 -0     albumwidgetstack.cpp  
 M  +2 -0      albumwidgetstack.h  
 M  +22 -23    digikamapp.cpp  
 M  +1 -1      digikamapp.h  
 M  +0 -3      digikamappprivate.h  
 M  +48 -7     digikamview.cpp  
 M  +4 -1      digikamview.h  
 M  +5 -0      imagepreviewwidget.cpp  
 M  +1 -0      imagepreviewwidget.h  


--- trunk/extragear/graphics/digikam/digikam/albumwidgetstack.cpp #651638:651639
 @ -228,4 +228,14  @
     return d->imagePreviewView->minZoom();
 }
 
+void AlbumWidgetStack::setZoomFactor(double z)
+{
+    d->imagePreviewView->setZoomFactor(z);
+}
+
+double AlbumWidgetStack::zoomFactor()
+{
+    return d->imagePreviewView->zoomFactor();
+}
+
 }  // namespace Digikam
--- trunk/extragear/graphics/digikam/digikam/albumwidgetstack.h #651638:651639
 @ -72,6 +72,8  @
     void decreaseZoom();
     bool maxZoom();
     bool minZoom();
+    void setZoomFactor(double z);
+    double zoomFactor();
 
 signals:
 
--- trunk/extragear/graphics/digikam/digikam/digikamapp.cpp #651638:651639
 @ -174,9 +174,6  @
 
 DigikamApp::~DigikamApp()
 {
-    if (d->thumbSizeTimer)
-        delete d->thumbSizeTimer;
-
     ImageAttributesWatch::shutDown();
 
     if (ImageWindow::imagewindowCreated())
 @ -360,8 +357,11  @
     connect(d->thumbSizeSlider, SIGNAL(valueChanged(int)),
             this, SLOT(slotThumbSizeTimer(int)));
 
-    connect(d->view, SIGNAL(signalZoomChanged(int)),
+    connect(d->view, SIGNAL(signalThumbSizeChanged(int)),
             this, SLOT(slotThumbSizeChanged(int)));
+
+    connect(d->view, SIGNAL(signalZoomChanged(double)),
+            this, SLOT(slotZoomChanged(double)));
     
     connect(d->view, SIGNAL(signalTogglePreview(bool)),
             this, SLOT(slotTooglePreview(bool)));
 @ -918,7 +918,7  @
     d->imageSortAction->setCurrentItem((int)d->albumSettings->getImageSortOrder());
 
     d->thumbSizeSlider->setValue(d->albumSettings->getDefaultIconSize());
-    slotThumbSizeEffect();
+    slotThumbSizeChanged(d->thumbSizeSlider->value());
 }
 
 void DigikamApp::enableThumbSizePlusAction(bool val)
 @ -1794,30 +1794,31  @
 
 void DigikamApp::slotThumbSizeTimer(int size)
 {
-    d->thumbSizeTracker->setText(i18n("Thumbnail size: %1").arg(size));
-
-    if (d->thumbSizeTimer)
-    {
-       d->thumbSizeTimer->stop();
-       delete d->thumbSizeTimer;
-    }
-
-    d->thumbSizeTimer = new QTimer( this );
-    connect(d->thumbSizeTimer, SIGNAL(timeout()),
-            this, SLOT(slotThumbSizeEffect()) );
-    d->thumbSizeTimer->start(300, true);
+    d->view->setThumbSize(size);
 }
 
-void DigikamApp::slotThumbSizeEffect()
+void DigikamApp::slotThumbSizeChanged(int size)
 {
-    d->view->setThumbSize(d->thumbSizeSlider->value());
+    d->thumbSizeSlider->blockSignals(true);
+    d->thumbSizeSlider->setValue(size);
+    d->thumbSizeTracker->setText(i18n("Thumbnail size: %1").arg(size));
+    d->thumbSizeSlider->blockSignals(false);
 }
 
-void DigikamApp::slotThumbSizeChanged(int size)
+void DigikamApp::slotZoomChanged(double zoom)
 {
     d->thumbSizeSlider->blockSignals(true);
+
+    double h    = (double)ThumbnailSize::Huge;
+    double s    = (double)ThumbnailSize::Small;
+    double zmin = 0.1;
+    double zmax = 10.0;
+    double b    = (zmin-(zmax*s/h))/(1-s/h);
+    double a    = (zmax-b)/h;
+    int size    = (int)((zoom - b) /a); 
+
     d->thumbSizeSlider->setValue(size);
-    d->thumbSizeTracker->setText(i18n("Thumbnail size: %1").arg(size));
+    d->thumbSizeTracker->setText(i18n("zoom: %1%").arg((int)(zoom*100.0)));
     d->thumbSizeSlider->blockSignals(false);
 }
 
 @ -1825,8 +1826,6  @
 {
     // NOTE: if 't' is true, we are in Preview Mode, else we are in AlbumView Mode
 
-    d->thumbSizeSlider->setEnabled(!t);
-
     // This is require if ESC is pressed to go out of Preview Mode. 
     // imagePreviewAction is handled by F3 key only. 
     d->imagePreviewAction->setChecked(t);
--- trunk/extragear/graphics/digikam/digikam/digikamapp.h #651638:651639
 @ -154,8 +154,8  @
     void slotProgressValue(int);
 
     void slotThumbSizeTimer(int);
-    void slotThumbSizeEffect();
     void slotThumbSizeChanged(int);
+    void slotZoomChanged(double);
     void slotTooglePreview(bool);
 
 private:
--- trunk/extragear/graphics/digikam/digikam/digikamappprivate.h #651638:651639
 @ -130,7 +130,6  @
         view                                 = 0;
         splashScreen                         = 0;
         thumbSizeSlider                      = 0;
-        thumbSizeTimer                       = 0;
         thumbSizeTracker                     = 0;
     }
 
 @ -145,8 +144,6  @
     QPtrList<KAction>      kipiBatchActions;
     QPtrList<KAction>      kipiAlbumActions;
 
-    QTimer                *thumbSizeTimer;
-
     QSlider               *thumbSizeSlider;
 
     QMap<int, QString>     mediaItems;
--- trunk/extragear/graphics/digikam/digikam/digikamview.cpp #651638:651639
 @ -101,6 +101,7  @
         tagFilterView         = 0;
         albumWidgetStack      = 0;
         selectionTimer        = 0;
+        thumbSizeTimer        = 0;
         needDispatchSelection = false;
         cancelSlideShow       = false;
     }
 @ -109,10 +110,12  @
     bool                      cancelSlideShow;
 
     int                       initialAlbumID;
+    int                       thumbSize;
 
     QSplitter                *splitter;
 
     QTimer                   *selectionTimer;
+    QTimer                   *thumbSizeTimer;
 
     DigikamApp               *parent;
 
 @ -178,6 +181,9  @
 
 DigikamView::~DigikamView()
 {
+    if (d->thumbSizeTimer)
+        delete d->thumbSizeTimer;
+
     saveViewState();
 
     delete d->albumHistory;
 @ -706,19 +712,50  @
 
 void DigikamView::setThumbSize(int size)
 {
-    if (size > ThumbnailSize::Huge || size < ThumbnailSize::Small)
-        return;
+    if (d->albumWidgetStack->previewMode() == AlbumWidgetStack::PreviewImageMode)
+    {
+        double h    = (double)ThumbnailSize::Huge;
+        double s    = (double)ThumbnailSize::Small;
+        double zmin = 0.1;
+        double zmax = 10.0;
+        double b    = (zmin-(zmax*s/h))/(1-s/h);
+        double a    = (zmax-b)/h;
+        double z    = a*size+b; 
+        d->albumWidgetStack->setZoomFactor(z);   
+        emit signalZoomChanged(d->albumWidgetStack->zoomFactor());
+    }
+    else if (d->albumWidgetStack->previewMode() == AlbumWidgetStack::PreviewAlbumMode)
+    {
+        if (size > ThumbnailSize::Huge || size < ThumbnailSize::Small)
+            return;
 
+        emit signalThumbSizeChanged(size);
+        d->thumbSize = size;
+
+        if (d->thumbSizeTimer)
+        {
+            d->thumbSizeTimer->stop();
+            delete d->thumbSizeTimer;
+        }
+    
+        d->thumbSizeTimer = new QTimer( this );
+        connect(d->thumbSizeTimer, SIGNAL(timeout()),
+                this, SLOT(slotThumbSizeEffect()) );
+        d->thumbSizeTimer->start(300, true);    
+    }
+}
+
+void DigikamView::slotThumbSizeEffect()
+{
     emit signalNoCurrentItem();
 
-    d->iconView->setThumbnailSize(size);
-
+    d->iconView->setThumbnailSize(d->thumbSize);
     toogleZoomActions();
 
     AlbumSettings* settings = AlbumSettings::instance();
     if (!settings)
         return;
-    settings->setDefaultIconSize(size);
+    settings->setDefaultIconSize(d->thumbSize);
 }
 
 void DigikamView::toogleZoomActions()
 @ -755,12 +792,13  @
     {
         int newSize = d->iconView->thumbnailSize().size() + ThumbnailSize::Step; 
         setThumbSize(newSize);
-        emit signalZoomChanged(newSize);
+        emit signalThumbSizeChanged(newSize);
     }
     else if (d->albumWidgetStack->previewMode() == AlbumWidgetStack::PreviewImageMode)
     {
         d->albumWidgetStack->increaseZoom();
         toogleZoomActions();
+        emit signalZoomChanged(d->albumWidgetStack->zoomFactor());
     }
 }
 
 @ -770,12 +808,13  @
     {
         int newSize = d->iconView->thumbnailSize().size() - ThumbnailSize::Step; 
         setThumbSize(newSize);
-        emit signalZoomChanged(newSize);
+        emit signalThumbSizeChanged(newSize);
     }  
     else if (d->albumWidgetStack->previewMode() == AlbumWidgetStack::PreviewImageMode)
     {
         d->albumWidgetStack->decreaseZoom();
         toogleZoomActions();
+        emit signalZoomChanged(d->albumWidgetStack->zoomFactor());
     }
 }
 
 @ -912,11 +951,13  @
             nextInfo = static_cast<AlbumIconItem*>(iconItem->nextItem())->imageInfo();
 
         d->albumWidgetStack->setPreviewItem(iconItem->imageInfo(), previousInfo, nextInfo);
+        emit signalZoomChanged(d->albumWidgetStack->zoomFactor());
     }
     else
     {
         // We go back to AlbumView Mode.
         d->albumWidgetStack->setPreviewMode( AlbumWidgetStack::PreviewAlbumMode );
+        emit signalThumbSizeChanged(d->iconView->thumbnailSize().size());
     }
 }
 
--- trunk/extragear/graphics/digikam/digikam/digikamview.h #651638:651639
 @ -72,7 +72,8  @
     void signalNoCurrentItem();
     void signalProgressBarMode(int, const QString&);
     void signalProgressValue(int);
-    void signalZoomChanged(int);
+    void signalThumbSizeChanged(int);
+    void signalZoomChanged(double);
     void signalTogglePreview(bool);
 
 public slots:
 @ -168,6 +169,8  @
     void slotEscapePreview();
     void slotCancelSlideShow();
 
+    void slotThumbSizeEffect();
+
 private:
 
     DigikamViewPriv* d;
--- trunk/extragear/graphics/digikam/digikam/imagepreviewwidget.cpp #651638:651639
 @ -437,6 +437,11  @
     viewport()->update();
 }
 
+double ImagePreviewWidget::zoomFactor()
+{
+    return d->zoom; 
+}
+
 bool ImagePreviewWidget::fitToWindow()
 {
     return d->autoZoom;
--- trunk/extragear/graphics/digikam/digikam/imagepreviewwidget.h #651638:651639
 @ -50,6 +50,7  @
 
     void setImage(const QImage& image);
     void setZoomFactor(double z);
+    double zoomFactor();
     bool fitToWindow();
     void toggleFitToWindow();
     bool maxZoom();



More information about the Digikam-devel mailing list