diff options
Diffstat (limited to 'lib')
-rw-r--r-- | lib/tdeqt4converter.cpp | 3 | ||||
-rw-r--r-- | lib/tdeqt4painter.cpp | 26 |
2 files changed, 25 insertions, 4 deletions
diff --git a/lib/tdeqt4converter.cpp b/lib/tdeqt4converter.cpp index 3c5675d..e4358bd 100644 --- a/lib/tdeqt4converter.cpp +++ b/lib/tdeqt4converter.cpp @@ -117,6 +117,7 @@ TQPixmap convertQt4ToTQt3Pixmap(QPixmap qt4pixmap, bool copyTransparency, TQColo { TQPixmap tqtPM(qt4pixmap.width(), qt4pixmap.height(), (copyTransparency)?qt4pixmap.depth():((qt4pixmap.depth()>24)?24:qt4pixmap.depth())); QPixmap qtPM = QPixmap::fromX11Pixmap(tqtPM.handle(), QPixmap::ExplicitlyShared); + qtPM.detach(); if (copyTransparency) { qtPM.fill(Qt::transparent); @@ -180,6 +181,7 @@ TQPixmap convertQt4IconToTQt3Pixmap(QIcon qt4icon, int iconsize, TQPixmapCache* QIcon convertTQt3PixmapToQt4Icon(TQPixmap tqt3pixmap) { QPixmap qt4pm = QPixmap::fromX11Pixmap(tqt3pixmap.handle(), QPixmap::ImplicitlyShared); + qt4pm.detach(); return QIcon(qt4pm); } @@ -313,6 +315,7 @@ QBrush convertTQt3ToQt4Brush(TQBrush tqt3brush) if (qt4brushstyle == Qt::TexturePattern) { TQPixmap tqtPM = *tqt3brush.pixmap(); QPixmap qtPM = QPixmap::fromX11Pixmap(tqtPM.handle(), QPixmap::ImplicitlyShared); + qtPM.detach(); qt4brush.setTexture(qtPM); } diff --git a/lib/tdeqt4painter.cpp b/lib/tdeqt4painter.cpp index 2e22ebf..a51e7e2 100644 --- a/lib/tdeqt4painter.cpp +++ b/lib/tdeqt4painter.cpp @@ -34,7 +34,8 @@ #define SET_BIT(x, y) (x |= 1 << y) #define TEST_BIT(x, y) ((x & (1 << y)) >> y) -// #define USE_FROMX11_PIXMAP +// When the time comes that Qt4/Qt5 are no longer able to use X11 data structures, unset this define... +#define USE_QT4_FROM_X11_PIXMAP_FUNCTIONS /*! \class TDEQt4PaintDevice tdeqt4painter.h @@ -126,7 +127,7 @@ bool TDEQt4PaintDevice::cmd( int c, TQPainter *pt, TQPDevCmdParam *p ) // SLOW TQRect tqt3br = p[0].rgn->boundingRect(); if (!tqt3br.isNull()) { -#ifdef USE_FROMX11_PIXMAP +#ifdef USE_QT4_FROM_X11_PIXMAP_FUNCTIONS TQBitmap regionMask(tqt3br.x()+tqt3br.width(), tqt3br.y()+tqt3br.height()); regionMask.fill(TQt::color0); TQPainter tqt3brpainter(®ionMask); @@ -134,7 +135,8 @@ bool TDEQt4PaintDevice::cmd( int c, TQPainter *pt, TQPDevCmdParam *p ) tqt3brpainter.fillRect(0,0,regionMask.width(),regionMask.height(),TQt::color1); tqt3brpainter.end(); QBitmap qt4RegionMask = QPixmap::fromX11Pixmap(regionMask.handle(), QPixmap::ImplicitlyShared); -#else // USE_FROMX11_PIXMAP + qt4RegionMask.detach(); +#else // USE_QT4_FROM_X11_PIXMAP_FUNCTIONS TQBitmap regionMask(tqt3br.x()+tqt3br.width(), tqt3br.y()+tqt3br.height(), 32); int width = regionMask.width(); int height = regionMask.height(); @@ -159,7 +161,7 @@ bool TDEQt4PaintDevice::cmd( int c, TQPainter *pt, TQPDevCmdParam *p ) } QBitmap qt4RegionMask = QBitmap::fromData(QSize(width, height), monoData, QImage::Format_Mono); free(monoData); -#endif // USE_FROMX11_PIXMAP +#endif // USE_QT4_FROM_X11_PIXMAP_FUNCTIONS qt4region = QRegion(qt4RegionMask); #endif TQPainter::CoordinateMode tqt3coordmode = (TQPainter::CoordinateMode)p[1].ival; @@ -372,8 +374,16 @@ bool TDEQt4PaintDevice::cmd( int c, TQPainter *pt, TQPDevCmdParam *p ) TQColor qt3color = p[0].brush->color(); qt4brush.setColor(QColor(qt3color.red(), qt3color.green(), qt3color.blue(), 255)); if (qt4brushstyle == Qt::TexturePattern) { +#ifdef USE_QT4_FROM_X11_PIXMAP_FUNCTIONS TQPixmap tqtPM = *p[0].brush->pixmap(); QPixmap qtPM = QPixmap::fromX11Pixmap(tqtPM.handle(), QPixmap::ImplicitlyShared); + qtPM.detach(); +#else // USE_QT4_FROM_X11_PIXMAP_FUNCTIONS + TQImage qt3image = (*p[0].brush->pixmap()).convertToImage(); + qt3image = qt3image.convertDepth(32); + QImage qt4image(qt3image.bits(), qt3image.width(), qt3image.height(), QImage::Format_ARGB32); + QPixmap qtPM = QPixmap::fromImage(qt4image); +#endif // USE_QT4_FROM_X11_PIXMAP_FUNCTIONS qt4brush.setTexture(qtPM); } } @@ -491,7 +501,15 @@ bool TDEQt4PaintDevice::cmd( int c, TQPainter *pt, TQPDevCmdParam *p ) if (c == PdcDrawPixmap) { qt4rect = QRect(p[0].rect->x(), p[0].rect->y(), p[0].rect->width(), p[0].rect->height()); TQPixmap qt3pixmap = *p[1].pixmap; +#ifdef USE_QT4_FROM_X11_PIXMAP_FUNCTIONS qt4pixmap = QPixmap::fromX11Pixmap(qt3pixmap.handle(), QPixmap::ImplicitlyShared); + qt4pixmap.detach(); +#else // USE_QT4_FROM_X11_PIXMAP_FUNCTIONS + TQImage qt3image = qt3pixmap.convertToImage(); + qt3image = qt3image.convertDepth(32); + QImage qt4image(qt3image.bits(), qt3image.width(), qt3image.height(), QImage::Format_ARGB32); + qt4pixmap = QPixmap::fromImage(qt4image); +#endif // USE_QT4_FROM_X11_PIXMAP_FUNCTIONS } if (c == PdcDrawText2) { qt4point1 = QPoint(p[0].point->x(), p[0].point->y()); |