Bug 104895

Summary: Screenshots are not rescaled when resizing window
Product: [Applications] ksnapshot Reporter: Karl Ove Hufthammer <karl>
Component: generalAssignee: Richard Moore <rich>
Status: RESOLVED FIXED    
Severity: normal    
Priority: NOR    
Version: unspecified   
Target Milestone: ---   
Platform: Compiled Sources   
OS: Linux   
Latest Commit: Version Fixed In:
Attachments: Patch for this bug

Description Karl Ove Hufthammer 2005-05-01 09:39:56 UTC
Version:            (using KDE Devel)
Installed from:    Compiled sources

When resizing (enlarging) the KSnapshow window, the screenshot thumbnail is not rescaled to fit the  available space. It should.

Also, the lower panel (the area over the horizontal line) is resized vertically. It should not, since it doesn't contain any text to fill the added vertical space. Only the upper panel should be resized.
Comment 1 Isaac Clerencia 2005-05-01 17:32:11 UTC
> Also, the lower panel (the area over the horizontal line) is resized 
> vertically. It should not, since it doesn't contain any text to fill the
> added vertical space. Only the upper panel should be resized. 
I agree, removing the widget named "spacer3" from ksnapshot/ksnapshotwidget.ui fixes it, leaving more space for the snapshot preview.
Comment 2 Isaac Clerencia 2005-05-07 11:51:34 UTC
Created attachment 10926 [details]
Patch for this bug

This patch should "fix" this bug. As it is my first patch I should be carefully
reviewed, I'm not sure if this is the best way to do it or even if I'm breaking
anything else, but it's working here against latest SVN :)

Best regards
Comment 3 Stephan Binner 2005-05-07 13:41:50 UTC
SVN commit 410274 by binner:

Rescale screenshot preview when resizing window
Patch by Isaac Clerencia <isaac@sindominio.net>
BUG: 104895


 M  +9 -0      branches/KDE/3.4/kdegraphics/ksnapshot/ksnapshot.cpp  
 M  +3 -1      branches/KDE/3.4/kdegraphics/ksnapshot/ksnapshot.h  


--- branches/KDE/3.4/kdegraphics/ksnapshot/ksnapshot.cpp #410273:410274
@@ -114,6 +114,7 @@
     }
 
     connect( &grabTimer, SIGNAL( timeout() ), this, SLOT(  grabTimerDone() ) );
+    connect( &updateTimer, SIGNAL( timeout() ), this, SLOT(  updatePreview() ) );
     QTimer::singleShot( 0, this, SLOT( updateCaption() ) );
 
     KHelpMenu *helpMenu = new KHelpMenu(this, KGlobal::instance()->aboutData(), false);
@@ -151,6 +152,14 @@
 {
 }
 
+void KSnapshot::resizeEvent( QResizeEvent *event)
+{
+	if( !updateTimer.isActive() )
+		updateTimer.start(200, true);
+	else	
+		updateTimer.changeInterval(200);
+}
+
 bool KSnapshot::save( const QString &filename )
 {
     return save( KURL::fromPathOrURL( filename ));
--- branches/KDE/3.4/kdegraphics/ksnapshot/ksnapshot.h #410273:410274
@@ -85,17 +85,18 @@
     void reject() { close(); }
 
     virtual void closeEvent( QCloseEvent * e );
+    void resizeEvent(QResizeEvent*);
     bool eventFilter( QObject*, QEvent* );
     
 private slots:
     void grabTimerDone();
     void slotDragSnapshot();
     void updateCaption();
+    void updatePreview();
     void slotRegionGrabbed( const QPixmap & );
 
 private:
     bool save( const KURL& url );
-    void updatePreview();
     void performGrab();
     void autoincFilename();
     int grabMode();
@@ -103,6 +104,7 @@
 
     QPixmap snapshot;
     QTimer grabTimer;
+    QTimer updateTimer;
     QWidget* grabber;
     KURL filename;
     KSnapshotWidget *mainWidget;