From kde-core-devel Mon Oct 28 23:23:41 2002 From: Helge Deller Date: Mon, 28 Oct 2002 23:23:41 +0000 To: kde-core-devel Subject: kpaint Patch (3) - was: [Patch:] KClipboard / klipper / kpaint bug fixes X-MARC-Message: https://marc.info/?l=kde-core-devel&m=103584756622062 MIME-Version: 1 Content-Type: multipart/mixed; boundary="--Boundary-00=_9bcv9N6bC8sTgmO" --Boundary-00=_9bcv9N6bC8sTgmO Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: 7bit Content-Disposition: inline last patch of the KClipboard / klipper / kpaint patches: - fix a few kpaint pixmap copy & paste problems - use the new KClipboard::provides() function to speed up menu "Edit"/"Paste" enabling function - check clipboards contents at startup to initialize the status of the "Edit"/"Paste" menu entries. - indenting fixes Helge --Boundary-00=_9bcv9N6bC8sTgmO Content-Type: text/plain; charset="iso-8859-1"; name="kpaint.patch" Content-Transfer-Encoding: 7bit Content-Disposition: inline; filename="kpaint.patch" Index: canvas.cpp =================================================================== RCS file: /home/kde/kdegraphics/kpaint/canvas.cpp,v retrieving revision 1.32 diff -u -p -r1.32 canvas.cpp --- canvas.cpp 2002/09/25 23:45:28 1.32 +++ canvas.cpp 2002/10/28 23:17:23 @@ -129,6 +129,9 @@ void Canvas::cut() int w = haveSelection_ ? selection_.right() - selection_.left() : pix->width(); int h = haveSelection_ ? selection_.bottom() - selection_.top() : pix->height(); + if (w <= 0 || h <= 0) + return; + QPixmap p( w, h ); p.fill(QColor("white")); @@ -141,16 +144,18 @@ void Canvas::cut() } void Canvas::copy() -{ - int x = haveSelection_ ? selection_.left() : 0; - int y = haveSelection_ ? selection_.top() : 0; - int w = haveSelection_ ? selection_.right() - selection_.left() : pix->width(); - int h = haveSelection_ ? selection_.bottom() - selection_.top() : pix->height(); - kdDebug(4400) << "copying: (" << x << ", " << y << ") - (" << w << ", " << h << ")"; +{ + int x = haveSelection_ ? selection_.left() : 0; + int y = haveSelection_ ? selection_.top() : 0; + int w = haveSelection_ ? selection_.right() - selection_.left() : pix->width(); + int h = haveSelection_ ? selection_.bottom() - selection_.top() : pix->height(); + kdDebug(4400) << "copying: (" << x << ", " << y << ") - (" << w << ", " << h << ")"; + if (w <= 0 || h <= 0) + return; - QPixmap clipboardPix( w, h ); - bitBlt( &clipboardPix, 0, 0, pix, x, y, w, h, CopyROP); - kapp->clipboard()->setPixmap( clipboardPix ); + QPixmap clipboardPix( w, h ); + bitBlt( &clipboardPix, 0, 0, pix, x, y, w, h, CopyROP); + kapp->clipboard()->setPixmap( clipboardPix ); } void Canvas::paste( int x, int y ) Index: kpaint.cpp =================================================================== RCS file: /home/kde/kdegraphics/kpaint/kpaint.cpp,v retrieving revision 1.105 diff -u -p -r1.105 kpaint.cpp --- kpaint.cpp 2002/09/25 23:45:28 1.105 +++ kpaint.cpp 2002/10/28 23:17:23 @@ -11,6 +11,7 @@ #include #include #include +#include #include #include #include @@ -60,6 +61,7 @@ KPaint::KPaint(const KURL & _url) : KMai initStatus(); readOptions(); + enableEditPaste(); connect( kapp->clipboard(), SIGNAL( dataChanged() ), SLOT( enableEditPaste() ) ); resize(640,480); show(); @@ -150,14 +152,7 @@ void KPaint::readOptions() void KPaint::enableEditPaste() { - QClipboard *cb = kapp->clipboard(); - - bool e; - if ( cb->pixmap().isNull() ) - e = false; - else - e = true; - + bool e = KClipboard::provides("image/"); kdDebug() << "kpaint: clipboard has image: " << e << endl; pasteAction->setEnabled( e ); pasteImageAction->setEnabled( e ); @@ -661,8 +656,8 @@ void KPaint::editPaste() kdDebug(4400) << "editPaste()\n" << endl; QClipboard *cb = kapp->clipboard(); - QPixmap clipPix = cb->pixmap(); - if ( !clipPix.isNull() ) + QPixmap clipPix = cb->pixmap(QClipboard::Clipboard); + if ( !clipPix.isNull() && clipPix.width() && clipPix.height() ) man->setCurrentTool(9); m_canvas->markModified(); --Boundary-00=_9bcv9N6bC8sTgmO--