Scale capture preview if it exceeds screen bounds

Signed-off-by: mio <stigma@disroot.org>
pull/15/head
mio 3 months ago
parent 173770f0f1
commit 000a65ca62

@ -6,6 +6,7 @@
#include <kpushbutton.h> #include <kpushbutton.h>
#include <kstatusbar.h> #include <kstatusbar.h>
#include <kstdguiitem.h> #include <kstdguiitem.h>
#include <tqapplication.h>
#include <tqdialog.h> #include <tqdialog.h>
#include <tqhbox.h> #include <tqhbox.h>
#include <tqlabel.h> #include <tqlabel.h>
@ -69,7 +70,16 @@ public:
, m_title( TheStream::prettyTitle() ) , m_title( TheStream::prettyTitle() )
{ {
(new TQVBoxLayout( this ))->setAutoAdd( true ); (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 ); TQHBox *box = new TQHBox( this );
KPushButton *o = new KPushButton( KStdGuiItem::save(), box ); KPushButton *o = new KPushButton( KStdGuiItem::save(), box );

Loading…
Cancel
Save