summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authormio <stigma@disroot.org>2024-08-20 19:31:44 +1000
committermio <stigma@disroot.org>2024-08-20 19:31:44 +1000
commit000a65ca625eca28b5912650325886a9454e05c3 (patch)
tree65d60a8d517863b6a2101d6227dcfc50c34a0ef8
parent173770f0f1ba17bda0fc0d71f244d32f170afdff (diff)
downloadcodeine-000a65ca625eca28b5912650325886a9454e05c3.tar.gz
codeine-000a65ca625eca28b5912650325886a9454e05c3.zip
Scale capture preview if it exceeds screen bounds
Signed-off-by: mio <stigma@disroot.org>
-rw-r--r--src/app/captureFrame.cpp12
1 files changed, 11 insertions, 1 deletions
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 <kpushbutton.h>
#include <kstatusbar.h>
#include <kstdguiitem.h>
+#include <tqapplication.h>
#include <tqdialog.h>
#include <tqhbox.h>
#include <tqlabel.h>
@@ -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 );