From 000a65ca625eca28b5912650325886a9454e05c3 Mon Sep 17 00:00:00 2001 From: mio Date: Tue, 20 Aug 2024 19:31:44 +1000 Subject: [PATCH] Scale capture preview if it exceeds screen bounds Signed-off-by: mio --- src/app/captureFrame.cpp | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/src/app/captureFrame.cpp b/src/app/captureFrame.cpp index 920e18a..4988999 100644 --- a/src/app/captureFrame.cpp +++ b/src/app/captureFrame.cpp @@ -6,6 +6,7 @@ #include #include #include +#include #include #include #include @@ -69,7 +70,16 @@ public: , m_title( TheStream::prettyTitle() ) { (new TQVBoxLayout( this ))->setAutoAdd( true ); - (new TQLabel( this ))->setPixmap( frame ); + + // Scale the image to fit within the current screen's size. + TQRect screenRect = tqApp->desktop()->availableGeometry( this ); + if ( screenRect.contains( frame.rect() ) ) { + (new TQLabel( this ))->setPixmap( frame ); + } else { + TQSize scaledSize = screenRect.size() * 0.9; + TQImage scaledImage = frame.scale( scaledSize, TQImage::ScaleMin ); + (new TQLabel( this ))->setPixmap( scaledImage ); + } TQHBox *box = new TQHBox( this ); KPushButton *o = new KPushButton( KStdGuiItem::save(), box );