summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTimothy Pearson <[email protected]>2012-09-22 15:56:06 -0500
committerTimothy Pearson <[email protected]>2012-09-22 15:56:06 -0500
commitb59fdf2c21b2b13c0dfc362a40182759af057343 (patch)
treef2f28bd725ad7f4f56b7867682087c08b241c6cb
parent4f0b6320a769925e69fa04ebd3358894e706b52e (diff)
downloadqt4-tqt-theme-engine-b59fdf2c21b2b13c0dfc362a40182759af057343.tar.gz
qt4-tqt-theme-engine-b59fdf2c21b2b13c0dfc362a40182759af057343.zip
Fix QtOctave failure and MDI pixmap problems
-rw-r--r--lib/tdeqt4converter.cpp3
-rw-r--r--lib/tdeqt4painter.cpp26
-rw-r--r--plugin/simplestyle.cpp37
3 files changed, 51 insertions, 15 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(&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());
diff --git a/plugin/simplestyle.cpp b/plugin/simplestyle.cpp
index d40d457..b20c2bd 100644
--- a/plugin/simplestyle.cpp
+++ b/plugin/simplestyle.cpp
@@ -99,6 +99,8 @@ extern Q_GUI_EXPORT _qt_filedialog_existing_directory_hook qt_filedialog_existin
#ifdef INTEGRATE_WITH_TDE
static QString TDEFileDialogOpenName(QWidget *parent, const QString &caption, const QString &dir, const QString &filter, QString *selectedFilter, QFileDialog::Options)
{
+ Q_UNUSED(selectedFilter);
+
if (parent) {
return convertTQt3ToQt4String(KFileDialog::getOpenFileNameWId(convertQt4ToTQt3String(dir), convertQt4ToTQt3String(filter), parent->winId(), convertQt4ToTQt3String(caption)));
}
@@ -109,6 +111,9 @@ static QString TDEFileDialogOpenName(QWidget *parent, const QString &caption, co
static QStringList TDEFileDialogOpenNames(QWidget *parent, const QString &caption, const QString &dir, const QString &filter, QString *selectedFilter, QFileDialog::Options)
{
+ Q_UNUSED(selectedFilter);
+ Q_UNUSED(parent);
+
// TQWidget* tqt3parent = TQT_TQWIDGET(TQWidget::find( parent->winId() ));
TQWidget* tqt3parent = 0;
return convertTQt3ToQt4StringList(KFileDialog::getOpenFileNames(convertQt4ToTQt3String(dir), convertQt4ToTQt3String(filter), tqt3parent, convertQt4ToTQt3String(caption)));
@@ -116,6 +121,8 @@ static QStringList TDEFileDialogOpenNames(QWidget *parent, const QString &captio
static QString TDEFileDialogSaveName(QWidget *parent, const QString &caption, const QString &dir, const QString &filter, QString *selectedFilter, QFileDialog::Options)
{
+ Q_UNUSED(selectedFilter);
+
if (parent) {
return convertTQt3ToQt4String(KFileDialog::getSaveFileNameWId(convertQt4ToTQt3String(dir), convertQt4ToTQt3String(filter), parent->winId(), convertQt4ToTQt3String(caption)));
}
@@ -126,6 +133,8 @@ static QString TDEFileDialogSaveName(QWidget *parent, const QString &caption, co
static QString TDEFileDialogSelectDirectory(QWidget *parent, const QString &caption, const QString &dir, QFileDialog::Options)
{
+ Q_UNUSED(parent);
+
TQWidget* tqt3parent = 0;
return convertTQt3ToQt4String(KFileDialog::getExistingDirectory(convertQt4ToTQt3String(dir), tqt3parent, convertQt4ToTQt3String(caption)));
}
@@ -243,7 +252,6 @@ Qt4TDEStyle::Qt4TDEStyle() : m_aboutData(NULL), m_tqApplication(NULL), m_tdeAppl
// How a bug of this magnitude could go undetected in a major Qt4 release is beyond me...I guess cell phones don't generally use thin lines in their widgets!?
// This is Yet Another Example of why TDE cannot rely on Qt4 for anything of any real importance
printf("[WARNING] Qt4 >= Qt 4.8.0 detected; you are likely affected by these Qt4 bugs:\n\r[WARNING] https://bugreports.qt-project.org/browse/QTBUG-25896\n\r[WARNING] https://bugreports.qt-project.org/browse/QTBUG-26013\n\r[WARNING] There is no known workaround for this problem; your Qt4 application will display with numerous graphical glitches.\n\r");
- printf("[WARNING] You are also likely affected by a bug in QPixmap::fromX11Pixmap, which will result\n\r[WARNING] in qtoctave and similar applications failing to display, along with numerous BadDrawable errors!\n\r"); fflush(stdout);
#endif
}
@@ -621,6 +629,8 @@ QIcon Qt4TDEStyle::standardIconImplementation(StandardPixmap standardIcon, const
int Qt4TDEStyle::styleHint(StyleHint hint, const QStyleOption *opt, const QWidget *w, QStyleHintReturn* returnData) const
{
+ Q_UNUSED(returnData);
+
int retval = 0;
TQWidget* interfaceWidget = 0;
@@ -1064,7 +1074,6 @@ QSize Qt4TDEStyle::sizeFromContents(ContentsType type, const QStyleOption *opt,
TQStyleOption tqt3opt(TQStyleOption::Default);
TQMenuItem* drawingItem = 0;
- QAction* drawingAction = 0;
QList<QAction*> qt4menuactions;
int tqt3tabwidth = 0;
int tqt3iconwidth = 0;
@@ -1357,8 +1366,8 @@ int Qt4TDEStyle::pixelMetric(PixelMetric metric, const QStyleOption *opt, const
if (opt) {
m_tqt3generic_widget->setGeometry(0, 0, opt->rect.width(), opt->rect.height());
interfaceWidget = m_tqt3generic_widget;
+ retswitch = 1;
}
- retswitch = 1;
break;
case QStyle::PM_IndicatorWidth:
tqt3pixelmetric = TQStyle::PM_IndicatorWidth;
@@ -1605,7 +1614,9 @@ TQWidget* Qt4TDEStyle::initializeInterfaceWidget(TQt3WidgetType wt, const QWidge
TQComboBox* m_tqt3combobox_widget = 0;
TQSlider* m_tqt3slider_widget = 0;
TQScrollBar* m_tqt3scrollbar_widget = 0;
+#if 0
TQSpinBox* m_tqt3spinbox_widget = 0;
+#endif
TQSpinWidget* m_tqt3spinwidget_widget = 0;
TQTitleBar* m_tqt3titlebar_widget = 0;
TQMenuBar* m_tqt3menubar_widget = 0;
@@ -1623,7 +1634,9 @@ TQWidget* Qt4TDEStyle::initializeInterfaceWidget(TQt3WidgetType wt, const QWidge
m_tqt3combobox_widget = dynamic_cast<TQComboBox*>(cacheResult);
m_tqt3slider_widget = dynamic_cast<TQSlider*>(cacheResult);
m_tqt3scrollbar_widget = dynamic_cast<TQScrollBar*>(cacheResult);
+#if 0
m_tqt3spinbox_widget = dynamic_cast<TQSpinBox*>(cacheResult);
+#endif
m_tqt3spinwidget_widget = dynamic_cast<TQSpinWidget*>(cacheResult);
m_tqt3titlebar_widget = dynamic_cast<TQTitleBar*>(cacheResult);
m_tqt3menubar_widget = dynamic_cast<TQMenuBar*>(cacheResult);
@@ -1935,8 +1948,8 @@ TQWidget* Qt4TDEStyle::initializeInterfaceWidget(TQt3WidgetType wt, const QWidge
interfaceWidget = 0;
}
break;
-#if 0
case TQT3WT_TQSpinBox:
+#if 0
if (!m_tqt3spinbox_widget) m_tqt3spinbox_widget = new TQSpinBox(m_tqt3parent_widget);
interfaceWidget = m_tqt3spinbox_widget;
// Copy over all widget attributes
@@ -1955,8 +1968,8 @@ TQWidget* Qt4TDEStyle::initializeInterfaceWidget(TQt3WidgetType wt, const QWidge
}
interfaceWidget = 0;
}
- break;
#endif
+ break;
case TQT3WT_TQSpinWidget:
if (!m_tqt3spinwidget_widget) m_tqt3spinwidget_widget = new TQSpinWidget(m_tqt3parent_widget);
interfaceWidget = m_tqt3spinwidget_widget;
@@ -2005,11 +2018,15 @@ TQWidget* Qt4TDEStyle::initializeInterfaceWidget(TQt3WidgetType wt, const QWidge
m_tqt3toolbox_widget->setEnabled(qt4toolbox_widget->isEnabled());
// Remove all tabs
for (i=0;i<m_tqt3toolbox_widget->count();i++) {
- m_tqt3toolbox_widget->removeItem(m_tqt3toolbox_widget->item(i));
+ TQWidget* item = m_tqt3toolbox_widget->item(i);
+ m_tqt3toolbox_widget->removeItem(item);
+ if (item) {
+ delete item;
+ }
}
// Copy all tabs
for (i=0;i<qt4toolbox_widget->count();i++) {
- m_tqt3toolbox_widget->insertItem(i, m_tqt3generic_widget, convertQt4ToTQt3String(qt4toolbox_widget->itemText(i)));
+ m_tqt3toolbox_widget->insertItem(i, new TQWidget(m_tqt3parent_widget), convertQt4ToTQt3String(qt4toolbox_widget->itemText(i)));
}
}
else {
@@ -2046,6 +2063,8 @@ TQWidget* Qt4TDEStyle::initializeInterfaceWidget(TQt3WidgetType wt, const QWidge
interfaceWidget = 0;
}
break;
+ case TQT3WT_NONE:
+ break;
}
if ((qt4objectptr) && (!cacheResult) && (interfaceWidget)) {
@@ -2067,8 +2086,6 @@ void Qt4TDEStyle::handleQt4ObjectDestroyed(QObject* obj) {
QRect Qt4TDEStyle::subElementRect(SubElement element, const QStyleOption *opt, const QWidget *w) const
{
- TQStyle::SFlags sflags = 0;
-
bool can_override = true;
TQStyle::SubRect tqtSR;
@@ -2110,8 +2127,6 @@ QRect Qt4TDEStyle::subElementRect(SubElement element, const QStyleOption *opt, c
QRect Qt4TDEStyle::subControlRect(ComplexControl control, const QStyleOptionComplex* opt, SubControl subControl, const QWidget* w) const
{
- TQStyle::SFlags sflags = 0;
-
bool can_override = true;
TQStyle::ComplexControl tqtCC;
TQStyle::SubControl tqtSC;