summaryrefslogtreecommitdiffstats
path: root/lib/tdeqt4painter.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'lib/tdeqt4painter.cpp')
-rw-r--r--lib/tdeqt4painter.cpp26
1 files changed, 22 insertions, 4 deletions
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(&regionMask);
@@ -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());