From b7a7959cebb9e4dc13cda0f0d23ff16a110c5838 Mon Sep 17 00:00:00 2001 From: Anders Bakken Date: Wed, 24 Jun 2009 14:12:15 -0700 Subject: Make sure simplePen gets set properly The logic regarding whether or not a pen was simple was broken. Essentially the pen is sonly simple if it should en up as a single pixel line. Reviewed-by: Donald --- src/plugins/gfxdrivers/directfb/qdirectfbpaintengine.cpp | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/src/plugins/gfxdrivers/directfb/qdirectfbpaintengine.cpp b/src/plugins/gfxdrivers/directfb/qdirectfbpaintengine.cpp index 3425d08..c77cd78 100644 --- a/src/plugins/gfxdrivers/directfb/qdirectfbpaintengine.cpp +++ b/src/plugins/gfxdrivers/directfb/qdirectfbpaintengine.cpp @@ -913,11 +913,17 @@ void QDirectFBPaintEnginePrivate::end() void QDirectFBPaintEnginePrivate::setPen(const QPen &p) { pen = p; - simplePen = (pen.style() == Qt::NoPen) || - (pen.style() == Qt::SolidLine - && !antialiased - && (pen.brush().style() == Qt::SolidPattern) - && (pen.widthF() <= 1 && scale != NoScale)); + if (pen.style() == Qt::NoPen) { + simplePen = true; + } else if (pen.style() == Qt::SolidLine + && !antialiased + && pen.brush().style() == Qt::SolidPattern + && pen.widthF() <= 1.0 + && (scale == NoScale || pen.isCosmetic())) { + simplePen = true; + } else { + simplePen = false; + } } void QDirectFBPaintEnginePrivate::setCompositionMode(QPainter::CompositionMode mode) -- cgit v0.12 From 592d9767f4299d7ad8a3b923cf0d272ec9c32861 Mon Sep 17 00:00:00 2001 From: Derick Hawcroft Date: Thu, 25 Jun 2009 07:15:18 +1000 Subject: Fixup ibase. delete -> delete [] --- src/sql/drivers/ibase/qsql_ibase.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/sql/drivers/ibase/qsql_ibase.cpp b/src/sql/drivers/ibase/qsql_ibase.cpp index ef48ec0..0033418 100644 --- a/src/sql/drivers/ibase/qsql_ibase.cpp +++ b/src/sql/drivers/ibase/qsql_ibase.cpp @@ -157,8 +157,8 @@ static void delDA(XSQLDA *&sqlda) if (!sqlda) return; for (int i = 0; i < sqlda->sqld; ++i) { - delete sqlda->sqlvar[i].sqlind; - delete sqlda->sqlvar[i].sqldata; + delete [] sqlda->sqlvar[i].sqlind; + delete [] sqlda->sqlvar[i].sqldata; } free(sqlda); sqlda = 0; -- cgit v0.12 From 9d66697a72dd3c26ed744ffecab50722eb9adaee Mon Sep 17 00:00:00 2001 From: Anders Bakken Date: Wed, 24 Jun 2009 14:29:32 -0700 Subject: Fix a rendering issue Make sure surfaces always are locked when used as source for something. Reviewed-by: TrustMe --- src/plugins/gfxdrivers/directfb/qdirectfbpaintengine.cpp | 5 +++++ src/plugins/gfxdrivers/directfb/qdirectfbpixmap.cpp | 6 +++--- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/src/plugins/gfxdrivers/directfb/qdirectfbpaintengine.cpp b/src/plugins/gfxdrivers/directfb/qdirectfbpaintengine.cpp index c77cd78..3edef8f 100644 --- a/src/plugins/gfxdrivers/directfb/qdirectfbpaintengine.cpp +++ b/src/plugins/gfxdrivers/directfb/qdirectfbpaintengine.cpp @@ -567,6 +567,7 @@ void QDirectFBPaintEngine::drawPixmap(const QRectF &r, const QPixmap &pixmap, QPixmapData *data = pixmap.pixmapData(); Q_ASSERT(data->classId() == QPixmapData::DirectFBClass); QDirectFBPixmapData *dfbData = static_cast(data); + dfbData->unlockDirectFB(); IDirectFBSurface *s = dfbData->directFBSurface(); d->blit(r, s, sr); } @@ -598,6 +599,10 @@ void QDirectFBPaintEngine::drawTiledPixmap(const QRectF &r, QRasterPaintEngine::drawTiledPixmap(r, pix, sp); } else { d->unlock(); + QPixmapData *data = pixmap.pixmapData(); + Q_ASSERT(data->classId() == QPixmapData::DirectFBClass); + QDirectFBPixmapData *dfbData = static_cast(data); + dfbData->unlockDirectFB(); d->drawTiledPixmap(r, pixmap); } } diff --git a/src/plugins/gfxdrivers/directfb/qdirectfbpixmap.cpp b/src/plugins/gfxdrivers/directfb/qdirectfbpixmap.cpp index c2048d8..ce3d6e4 100644 --- a/src/plugins/gfxdrivers/directfb/qdirectfbpixmap.cpp +++ b/src/plugins/gfxdrivers/directfb/qdirectfbpixmap.cpp @@ -81,11 +81,9 @@ void QDirectFBPixmapData::resize(int width, int height) qWarning("QDirectFBPixmapData::resize(): Unable to allocate surface"); return; } - setSerialNumber(++global_ser_no); } - // mostly duplicated from qimage.cpp (QImageData::checkForAlphaPixels) static bool checkForAlphaPixels(const QImage &img) { @@ -200,6 +198,7 @@ void QDirectFBPixmapData::copy(const QPixmapData *data, const QRect &rect) QPixmapData::copy(data, rect); return; } + unlockDirectFB(); IDirectFBSurface *src = static_cast(data)->directFBSurface(); alpha = data->hasAlphaChannel(); @@ -282,10 +281,10 @@ void QDirectFBPixmapData::fill(const QColor &color) QPixmap QDirectFBPixmapData::transformed(const QTransform &transform, Qt::TransformationMode mode) const { + QDirectFBPixmapData *that = const_cast(this); if (!dfbSurface || transform.type() != QTransform::TxScale || mode != Qt::FastTransformation) { - QDirectFBPixmapData *that = const_cast(this); const QImage *image = that->buffer(); Q_ASSERT(image); const QImage transformed = image->transformed(transform, mode); @@ -294,6 +293,7 @@ QPixmap QDirectFBPixmapData::transformed(const QTransform &transform, data->fromImage(transformed, Qt::AutoColor); return QPixmap(data); } + that->unlockDirectFB(); int w, h; dfbSurface->GetSize(dfbSurface, &w, &h); -- cgit v0.12 From 74e782be57f22e41aeb6aa4bbec4e2921243097c Mon Sep 17 00:00:00 2001 From: Anders Bakken Date: Wed, 24 Jun 2009 14:40:39 -0700 Subject: Fix off by one bug in DirectFBPaintEngine This bug made us call lock more than we needed to. Reviewed-by: Donald --- src/plugins/gfxdrivers/directfb/qdirectfbpaintengine.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/plugins/gfxdrivers/directfb/qdirectfbpaintengine.cpp b/src/plugins/gfxdrivers/directfb/qdirectfbpaintengine.cpp index 3edef8f..40bec0e 100644 --- a/src/plugins/gfxdrivers/directfb/qdirectfbpaintengine.cpp +++ b/src/plugins/gfxdrivers/directfb/qdirectfbpaintengine.cpp @@ -378,7 +378,7 @@ void QDirectFBPaintEngine::clip(const QVectorPath &path, Qt::ClipOperation op) Q_D(QDirectFBPaintEngine); d->dirtyClip = true; const QPoint bottom = d->transform.map(QPoint(0, int(path.controlPointRect().y2))); - if (bottom.y() >= d->lastLockedHeight) + if (bottom.y() > d->lastLockedHeight) d->lock(); QRasterPaintEngine::clip(path, op); } @@ -389,7 +389,7 @@ void QDirectFBPaintEngine::clip(const QRect &rect, Qt::ClipOperation op) d->dirtyClip = true; if (d->clip() && !d->clip()->hasRectClip && d->clip()->enabled) { const QPoint bottom = d->transform.map(QPoint(0, rect.bottom())); - if (bottom.y() >= d->lastLockedHeight) + if (bottom.y() > d->lastLockedHeight) d->lock(); } -- cgit v0.12 From 10977eb209e743cf0010fd43ecf66f96815fad2f Mon Sep 17 00:00:00 2001 From: Derick Hawcroft Date: Thu, 25 Jun 2009 08:24:50 +1000 Subject: save on a couple of mallocs --- src/sql/drivers/psql/qsql_psql.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/sql/drivers/psql/qsql_psql.cpp b/src/sql/drivers/psql/qsql_psql.cpp index ed9b98c..770df4c 100644 --- a/src/sql/drivers/psql/qsql_psql.cpp +++ b/src/sql/drivers/psql/qsql_psql.cpp @@ -834,7 +834,7 @@ bool QPSQLDriver::commitTransaction() if (d->pro == QPSQLDriver::Version8 || d->pro == QPSQLDriver::Version81 || d->pro == QPSQLDriver::Version82) { - transaction_failed = QByteArray(PQcmdStatus(res)) == QByteArray("ROLLBACK")?true:false; + transaction_failed = qstrcmp(PQcmdStatus(res), "ROLLBACK") == 0; } if (!res || PQresultStatus(res) != PGRES_COMMAND_OK || transaction_failed) { -- cgit v0.12 From 6198e74a0b482c332f7b6432b817831560fe21ec Mon Sep 17 00:00:00 2001 From: Prasanth Ullattil Date: Thu, 25 Jun 2009 11:38:28 +0200 Subject: Cannot move fixed size windows using titlebar (only on top edge) WM_NCHITTEST has to return the location type based on the position, instead of returning just true or false. Reviewed-by: Marius Storm-Olsen --- src/gui/kernel/qapplication_win.cpp | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/src/gui/kernel/qapplication_win.cpp b/src/gui/kernel/qapplication_win.cpp index 0c74cfa..324fac7 100644 --- a/src/gui/kernel/qapplication_win.cpp +++ b/src/gui/kernel/qapplication_win.cpp @@ -1905,10 +1905,14 @@ LRESULT CALLBACK QtWndProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam // don't show resize-cursors for fixed-size widgets QRect fs = widget->frameStrut(); if (!widget->isMinimized()) { + if (widget->minimumHeight() == widget->maximumHeight()) { + if (pos.y() < -(fs.top() - fs.left())) + return HTCAPTION; + if (pos.y() >= widget->height()) + return HTBORDER; + } if (widget->minimumWidth() == widget->maximumWidth() && (pos.x() < 0 || pos.x() >= widget->width())) - break; - if (widget->minimumHeight() == widget->maximumHeight() && (pos.y() < -(fs.top() - fs.left()) || pos.y() >= widget->height())) - break; + return HTBORDER; } } -- cgit v0.12 From 4b9784fcdd7321a5d82b8ae73edd1ae52786d7ad Mon Sep 17 00:00:00 2001 From: Thiago Macieira Date: Thu, 25 Jun 2009 11:32:06 +0200 Subject: Change QSharedPointer to track (or not) pointers when the #define is enabled. This allows mixing of debug and non-debug code (possible on Unix systems) without causing assertion failures. Reviewed-by: Bradley T. Hughes --- src/corelib/tools/qsharedpointer_impl.h | 6 ++++-- src/corelib/tools/tools.pri | 2 ++ tests/auto/qsharedpointer/tst_qsharedpointer.cpp | 3 ++- 3 files changed, 8 insertions(+), 3 deletions(-) diff --git a/src/corelib/tools/qsharedpointer_impl.h b/src/corelib/tools/qsharedpointer_impl.h index 928805a..0471a1b 100644 --- a/src/corelib/tools/qsharedpointer_impl.h +++ b/src/corelib/tools/qsharedpointer_impl.h @@ -48,6 +48,8 @@ #pragma qt_sync_stop_processing #endif +#include + QT_BEGIN_HEADER QT_BEGIN_NAMESPACE @@ -138,14 +140,14 @@ namespace QtSharedPointer { inline void internalConstruct(T *ptr) { -#ifndef QT_NO_DEBUG +#ifdef QT_SHAREDPOINTER_TRACK_POINTERS if (ptr) internalSafetyCheckAdd(ptr); #endif value = ptr; } inline void internalDestroy() { -#ifndef QT_NO_DEBUG +#ifdef QT_SHAREDPOINTER_TRACK_POINTERS if (value) internalSafetyCheckRemove(value); #endif } diff --git a/src/corelib/tools/tools.pri b/src/corelib/tools/tools.pri index e5bf7e4..b70c7df 100644 --- a/src/corelib/tools/tools.pri +++ b/src/corelib/tools/tools.pri @@ -26,6 +26,8 @@ HEADERS += \ tools/qregexp.h \ tools/qringbuffer_p.h \ tools/qshareddata.h \ + tools/qsharedpointer.h \ + tools/qsharedpointer_impl.h \ tools/qset.h \ tools/qsize.h \ tools/qstack.h \ diff --git a/tests/auto/qsharedpointer/tst_qsharedpointer.cpp b/tests/auto/qsharedpointer/tst_qsharedpointer.cpp index 795ce76..a11164f 100644 --- a/tests/auto/qsharedpointer/tst_qsharedpointer.cpp +++ b/tests/auto/qsharedpointer/tst_qsharedpointer.cpp @@ -39,7 +39,7 @@ ** ****************************************************************************/ - +#define QT_SHAREDPOINTER_TRACK_POINTERS #include "qsharedpointer.h" #include "externaltests.h" #include @@ -995,6 +995,7 @@ void tst_QSharedPointer::invalidConstructs() test.setDebugMode(true); test.setQtModules(QTest::QExternalTest::QtCore); test.setProgramHeader( + "#define QT_SHAREDPOINTER_TRACK_POINTERS\n" "#include \n" "\n" "struct Data { int i; };\n" -- cgit v0.12 From 0c1be3042e27bf1980afa14eb6b0990b78bdd15f Mon Sep 17 00:00:00 2001 From: Norwegian Rock Cat Date: Thu, 25 Jun 2009 11:24:09 +0200 Subject: Only instantiate the PICT pasteboard MIME when we have to. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 10.6 does a lot of image synthesis for us when we put up a tiff, which is great because we don't have to do a thing and it will work with all the applications out there. This means we don't need our PICT convertor on 10.6 for 32-bit apps. However, this magic doesn't exist in earlier versions of Mac OS X, so we have to keep it around (along with the QuickTime symbol resolving) there. Reviewed-by: Morten Sørvig --- src/gui/kernel/qmime_mac.cpp | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/gui/kernel/qmime_mac.cpp b/src/gui/kernel/qmime_mac.cpp index 31c66e4..903b677 100644 --- a/src/gui/kernel/qmime_mac.cpp +++ b/src/gui/kernel/qmime_mac.cpp @@ -502,6 +502,8 @@ QList QMacPasteboardMimeHTMLText::convertFromMime(const QString &mim #ifdef Q_WS_MAC32 +// This can be removed once 10.6 is the minimum (or we have to require 64-bit) whichever comes first. + #include #include @@ -1099,7 +1101,10 @@ void QMacPasteboardMime::initialize() //standard types that we wrap new QMacPasteboardMimeTiff; #ifdef Q_WS_MAC32 - new QMacPasteboardMimePict; + // 10.6 does automatic synthesis to and from PICT to standard image types (like TIFF), + // so don't bother doing it ourselves, especially since it's not available in 64-bit. + if (QSysInfo::MacintoshVersion < QSysInfo::MV_10_6) + new QMacPasteboardMimePict; #endif new QMacPasteboardMimeUnicodeText; new QMacPasteboardMimePlainText; -- cgit v0.12 From e3886938f27da1ed460de83235d9fd3d5abd4713 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Samuel=20R=C3=B8dal?= Date: Thu, 25 Jun 2009 12:38:38 +0200 Subject: Fixed buggy clipping when using projective transforms in GL 2 engine. The gl_Position x, y, and z coordinates are always divided by the homogenuous w coordinate to yield the final coordinates. Since we want the depth to be constant for the whole item we need to premultiply it by the w-coordinate. We can do this in the main() function in the vertex programs since all the vertex programs use the depth uniform, thus simplifying the programs a bit. Reviewed-by: Trond --- src/opengl/gl2paintengineex/qglengineshadersource_p.h | 18 ++++-------------- 1 file changed, 4 insertions(+), 14 deletions(-) diff --git a/src/opengl/gl2paintengineex/qglengineshadersource_p.h b/src/opengl/gl2paintengineex/qglengineshadersource_p.h index 4959b60..4e32f91 100644 --- a/src/opengl/gl2paintengineex/qglengineshadersource_p.h +++ b/src/opengl/gl2paintengineex/qglengineshadersource_p.h @@ -64,19 +64,23 @@ QT_MODULE(OpenGL) static const char* const qglslMainVertexShader = "\ + uniform highp float depth;\ void setPosition();\ void main(void)\ {\ setPosition();\ + gl_Position.z = depth * gl_Position.w;\ }"; static const char* const qglslMainWithTexCoordsVertexShader = "\ attribute lowp vec2 textureCoordArray; \ varying lowp vec2 textureCoords; \ + uniform highp float depth;\ void setPosition();\ void main(void) \ {\ setPosition();\ + gl_Position.z = depth * gl_Position.w;\ textureCoords = textureCoordArray; \ }"; @@ -84,20 +88,16 @@ static const char* const qglslMainWithTexCoordsVertexShader = "\ static const char* const qglslPositionOnlyVertexShader = "\ attribute highp vec4 vertexCoordsArray;\ uniform highp mat4 pmvMatrix;\ - uniform highp float depth;\ void setPosition(void)\ {\ gl_Position = pmvMatrix * vertexCoordsArray;\ - gl_Position.z = depth;\ }"; static const char* const qglslUntransformedPositionVertexShader = "\ attribute highp vec4 vertexCoordsArray;\ - uniform highp float depth;\ void setPosition(void)\ {\ gl_Position = vertexCoordsArray;\ - gl_Position.z = depth;\ }"; // Pattern Brush - This assumes the texture size is 8x8 and thus, the inverted size is 0.125 @@ -108,11 +108,9 @@ static const char* const qglslPositionWithPatternBrushVertexShader = "\ uniform mediump vec2 invertedTextureSize; \ uniform mediump mat3 brushTransform; \ varying mediump vec2 patternTexCoords; \ - uniform highp float depth;\ void setPosition(void) { \ gl_Position = pmvMatrix * vertexCoordsArray;\ gl_Position.xy = gl_Position.xy / gl_Position.w; \ - gl_Position.z = depth;\ mediump vec2 viewportCoords = (gl_Position.xy + 1.0) * halfViewportSize; \ mediump vec3 hTexCoords = brushTransform * vec3(viewportCoords, 1); \ mediump float invertedHTexCoordsZ = 1.0 / hTexCoords.z; \ @@ -142,11 +140,9 @@ static const char* const qglslPositionWithLinearGradientBrushVertexShader = "\ uniform highp vec3 linearData; \ uniform highp mat3 brushTransform; \ varying mediump float index ; \ - uniform highp float depth;\ void setPosition() { \ gl_Position = pmvMatrix * vertexCoordsArray;\ gl_Position.xy = gl_Position.xy / gl_Position.w; \ - gl_Position.z = depth;\ mediump vec2 viewportCoords = (gl_Position.xy + 1.0) * halfViewportSize; \ mediump vec3 hTexCoords = brushTransform * vec3(viewportCoords, 1); \ mediump float invertedHTexCoordsZ = 1.0 / hTexCoords.z; \ @@ -174,12 +170,10 @@ static const char* const qglslPositionWithConicalGradientBrushVertexShader = "\ uniform mediump vec2 halfViewportSize; \ uniform highp mat3 brushTransform; \ varying highp vec2 A; \ - uniform highp float depth;\ void setPosition(void)\ {\ gl_Position = pmvMatrix * vertexCoordsArray;\ gl_Position.xy = gl_Position.xy / gl_Position.w; \ - gl_Position.z = depth; \ mediump vec2 viewportCoords = (gl_Position.xy + 1.0) * halfViewportSize; \ mediump vec3 hTexCoords = brushTransform * vec3(viewportCoords, 1); \ mediump float invertedHTexCoordsZ = 1.0 / hTexCoords.z; \ @@ -215,12 +209,10 @@ static const char* const qglslPositionWithRadialGradientBrushVertexShader = "\ uniform highp vec2 fmp; \ varying highp float b; \ varying highp vec2 A; \ - uniform highp float depth;\ void setPosition(void) \ {\ gl_Position = pmvMatrix * vertexCoordsArray;\ gl_Position.xy = gl_Position.xy / gl_Position.w; \ - gl_Position.z = depth; \ mediump vec2 viewportCoords = (gl_Position.xy + 1.0) * halfViewportSize; \ mediump vec3 hTexCoords = brushTransform * vec3(viewportCoords, 1); \ mediump float invertedHTexCoordsZ = 1.0 / hTexCoords.z; \ @@ -254,11 +246,9 @@ static const char* const qglslPositionWithTextureBrushVertexShader = "\ uniform mediump vec2 invertedTextureSize; \ uniform mediump mat3 brushTransform; \ varying mediump vec2 brushTextureCoords; \ - uniform highp float depth;\ void setPosition(void) { \ gl_Position = pmvMatrix * vertexCoordsArray;\ gl_Position.xy = gl_Position.xy / gl_Position.w; \ - gl_Position.z = depth; \ mediump vec2 viewportCoords = (gl_Position.xy + 1.0) * halfViewportSize; \ mediump vec3 hTexCoords = brushTransform * vec3(viewportCoords, 1); \ mediump float invertedHTexCoordsZ = 1.0 / hTexCoords.z; \ -- cgit v0.12 From 9c4d6ec25ff1984b1e56363f3b8728ad7f256876 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Samuel=20R=C3=B8dal?= Date: Thu, 25 Jun 2009 12:42:09 +0200 Subject: Fixed missing restoration of state after a sync in the GL 2 engine. The sync() function properly sets up the state to allow using raw OpenGL commands with an active QPainter, but we also need to properly restore the state after sync() has been called and some other painting operation is done. Reviewed-by: Trond --- src/opengl/gl2paintengineex/qpaintengineex_opengl2.cpp | 12 ++++++++++-- src/opengl/gl2paintengineex/qpaintengineex_opengl2_p.h | 2 ++ 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/src/opengl/gl2paintengineex/qpaintengineex_opengl2.cpp b/src/opengl/gl2paintengineex/qpaintengineex_opengl2.cpp index 91df197..e24742f 100644 --- a/src/opengl/gl2paintengineex/qpaintengineex_opengl2.cpp +++ b/src/opengl/gl2paintengineex/qpaintengineex_opengl2.cpp @@ -654,6 +654,9 @@ void QGL2PaintEngineEx::sync() glDisable(GL_BLEND); glActiveTexture(GL_TEXTURE0); + + d->needsSync = true; + d->shaderManager->setDirty(); } void QGL2PaintEngineExPrivate::transferMode(EngineMode newMode) @@ -1216,6 +1219,7 @@ bool QGL2PaintEngineEx::begin(QPaintDevice *pdev) d->simpleShaderDepthUniformDirty = true; d->depthUniformDirty = true; d->opacityUniformDirty = true; + d->needsSync = false; d->use_system_clip = !systemClip().isEmpty(); @@ -1294,11 +1298,15 @@ void QGL2PaintEngineEx::ensureActive() ctx->d_ptr->active_engine = this; - glDisable(GL_DEPTH_TEST); + d->needsSync = true; + } + if (d->needsSync) { glViewport(0, 0, d->width, d->height); - + glDepthMask(false); + glDepthFunc(GL_LEQUAL); setState(state()); + d->needsSync = false; } } diff --git a/src/opengl/gl2paintengineex/qpaintengineex_opengl2_p.h b/src/opengl/gl2paintengineex/qpaintengineex_opengl2_p.h index 448964b..0d28a49 100644 --- a/src/opengl/gl2paintengineex/qpaintengineex_opengl2_p.h +++ b/src/opengl/gl2paintengineex/qpaintengineex_opengl2_p.h @@ -248,6 +248,8 @@ public: uint uniformIdentifiers[NumUniforms]; GLuint lastTexture; + + bool needsSync; }; QT_END_NAMESPACE -- cgit v0.12 From f4abd84cc63023eab6f666e841f66b9fa3d8be77 Mon Sep 17 00:00:00 2001 From: Thierry Bastian Date: Thu, 25 Jun 2009 15:33:05 +0200 Subject: QMAinWindow: Fixed autotest compilation after private API changes --- tests/auto/qmainwindow/tst_qmainwindow.cpp | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/tests/auto/qmainwindow/tst_qmainwindow.cpp b/tests/auto/qmainwindow/tst_qmainwindow.cpp index 80ba198..e46c2e1 100644 --- a/tests/auto/qmainwindow/tst_qmainwindow.cpp +++ b/tests/auto/qmainwindow/tst_qmainwindow.cpp @@ -1434,10 +1434,7 @@ void MoveSeparator::apply(QMainWindow *mw) const } QVERIFY(!path.isEmpty()); - QVector cache; - - l->layoutState.dockAreaLayout.separatorMove(path, QPoint(0, 0), QPoint(delta, delta), &cache); - + l->layoutState.dockAreaLayout.separatorMove(path, QPoint(0, 0), QPoint(delta, delta)); } QMap dockWidgetGeometries(QMainWindow *mw) -- cgit v0.12 From 553fb1b2e636cf14a193b1ca15bd08f755a452b3 Mon Sep 17 00:00:00 2001 From: Thierry Bastian Date: Thu, 25 Jun 2009 15:41:25 +0200 Subject: QToolBar: fixed a typo that would make the handle wider. --- src/gui/styles/qcommonstyle.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/gui/styles/qcommonstyle.cpp b/src/gui/styles/qcommonstyle.cpp index 24ff792..ed3bdb5 100644 --- a/src/gui/styles/qcommonstyle.cpp +++ b/src/gui/styles/qcommonstyle.cpp @@ -3197,7 +3197,7 @@ QRect QCommonStyle::subElementRect(SubElement sr, const QStyleOption *opt, //have all the information we need (ie. the layout's margin) const QToolBar *tb = qobject_cast(widget); const int margin = tb && tb->layout() ? tb->layout()->margin() : 2; - const int handleExtent = pixelMetric(QStyle::PM_ToolBarExtensionExtent, opt, tb); + const int handleExtent = pixelMetric(QStyle::PM_ToolBarHandleExtent, opt, tb); if (tbopt->state & QStyle::State_Horizontal) { r = QRect(margin, margin, handleExtent, tbopt->rect.height() - 2*margin); r = QStyle::visualRect(tbopt->direction, tbopt->rect, r); -- cgit v0.12 From d5b75962ee2e22b5a6b061430f936fc663d7122b Mon Sep 17 00:00:00 2001 From: Markus Goetz Date: Thu, 25 Jun 2009 15:45:07 +0200 Subject: QNAM HTTP Code: Uncluttering functions Uncluttered and duplicated some function to make it more clear what is happening. Was a bit confusing before if compressed data or uncompressed data is handled. Reviewed-by: Peter Hartmann --- src/network/access/qhttpnetworkconnection.cpp | 39 ++++++++++++++++++--------- src/network/access/qhttpnetworkconnection_p.h | 11 +++++--- src/network/access/qhttpnetworkreply.cpp | 4 +-- 3 files changed, 36 insertions(+), 18 deletions(-) diff --git a/src/network/access/qhttpnetworkconnection.cpp b/src/network/access/qhttpnetworkconnection.cpp index f0c694d..365ae8b 100644 --- a/src/network/access/qhttpnetworkconnection.cpp +++ b/src/network/access/qhttpnetworkconnection.cpp @@ -174,22 +174,29 @@ bool QHttpNetworkConnectionPrivate::isSocketReading(QAbstractSocket *socket) con } -void QHttpNetworkConnectionPrivate::appendData(QHttpNetworkReply &reply, const QByteArray &fragment, bool compressed) +void QHttpNetworkConnectionPrivate::appendUncompressedData(QHttpNetworkReply &reply, const QByteArray &fragment) { - QByteArray *ba = (compressed) ? &reply.d_func()->compressedData : &reply.d_func()->responseData; - ba->append(fragment); - return; + reply.d_func()->responseData.append(fragment); } -qint64 QHttpNetworkConnectionPrivate::bytesAvailable(const QHttpNetworkReply &reply, bool compressed) const +void QHttpNetworkConnectionPrivate::appendCompressedData(QHttpNetworkReply &reply, const QByteArray &fragment) { - const QByteArray *ba = (compressed) ? &reply.d_func()->compressedData : &reply.d_func()->responseData; - return ba->size(); + reply.d_func()->compressedData.append(fragment); } -qint64 QHttpNetworkConnectionPrivate::read(QHttpNetworkReply &reply, QByteArray &data, qint64 maxSize, bool compressed) +qint64 QHttpNetworkConnectionPrivate::uncompressedBytesAvailable(const QHttpNetworkReply &reply) const { - QByteArray *ba = (compressed) ? &reply.d_func()->compressedData : &reply.d_func()->responseData; + return reply.d_func()->responseData.size(); +} + +qint64 QHttpNetworkConnectionPrivate::compressedBytesAvailable(const QHttpNetworkReply &reply) const +{ + return reply.d_func()->compressedData.size(); +} + +qint64 QHttpNetworkConnectionPrivate::read(QHttpNetworkReply &reply, QByteArray &data, qint64 maxSize) +{ + QByteArray *ba = &reply.d_func()->responseData; if (maxSize == -1 || maxSize >= ba->size()) { // read the whole data data = *ba; @@ -524,12 +531,14 @@ bool QHttpNetworkConnectionPrivate::expand(QAbstractSocket *socket, QHttpNetwork Q_ASSERT(socket); Q_ASSERT(reply); - qint64 total = bytesAvailable(*reply, true); + qint64 total = compressedBytesAvailable(*reply); if (total >= CHUNK || dataComplete) { int i = indexOf(socket); // uncompress the data QByteArray content, inflated; - read(*reply, content, -1, true); + content = reply->d_func()->compressedData; + reply->d_func()->compressedData.clear(); + int ret = Z_OK; if (content.size()) ret = reply->d_func()->gunzipBodyPartially(content, inflated); @@ -537,7 +546,7 @@ bool QHttpNetworkConnectionPrivate::expand(QAbstractSocket *socket, QHttpNetwork if (ret >= retCheck) { if (inflated.size()) { reply->d_func()->totalProgress += inflated.size(); - appendData(*reply, inflated, false); + appendUncompressedData(*reply, inflated); if (shouldEmitSignals(reply)) { emit reply->readyRead(); // make sure that the reply is valid @@ -638,7 +647,11 @@ void QHttpNetworkConnectionPrivate::receiveReply(QAbstractSocket *socket, QHttpN fragment.open(QIODevice::WriteOnly); bytes = reply->d_func()->readBody(socket, &fragment); if (bytes) { - appendData(*reply, fragment.data(), reply->d_func()->autoDecompress); + if (reply->d_func()->autoDecompress) + appendCompressedData(*reply, fragment.data()); + else + appendUncompressedData(*reply, fragment.data()); + if (!reply->d_func()->autoDecompress) { reply->d_func()->totalProgress += fragment.size(); if (shouldEmitSignals(reply)) { diff --git a/src/network/access/qhttpnetworkconnection_p.h b/src/network/access/qhttpnetworkconnection_p.h index 64a6faa..bc4d948 100644 --- a/src/network/access/qhttpnetworkconnection_p.h +++ b/src/network/access/qhttpnetworkconnection_p.h @@ -254,9 +254,14 @@ public: bool pendingAuthSignal; // there is an incomplete authentication signal bool pendingProxyAuthSignal; // there is an incomplete proxy authentication signal - void appendData(QHttpNetworkReply &reply, const QByteArray &fragment, bool compressed); - qint64 bytesAvailable(const QHttpNetworkReply &reply, bool compressed = false) const; - qint64 read(QHttpNetworkReply &reply, QByteArray &data, qint64 maxSize, bool compressed); + void appendUncompressedData(QHttpNetworkReply &reply, const QByteArray &fragment); + void appendCompressedData(QHttpNetworkReply &reply, const QByteArray &fragment); + + qint64 uncompressedBytesAvailable(const QHttpNetworkReply &reply) const; + qint64 compressedBytesAvailable(const QHttpNetworkReply &reply) const; + + qint64 read(QHttpNetworkReply &reply, QByteArray &data, qint64 maxSize); + void emitReplyError(QAbstractSocket *socket, QHttpNetworkReply *reply, QNetworkReply::NetworkError errorCode); bool handleAuthenticateChallenge(QAbstractSocket *socket, QHttpNetworkReply *reply, bool isProxy, bool &resend); void allDone(QAbstractSocket *socket, QHttpNetworkReply *reply); diff --git a/src/network/access/qhttpnetworkreply.cpp b/src/network/access/qhttpnetworkreply.cpp index c4d4a9c..47fb6d1 100644 --- a/src/network/access/qhttpnetworkreply.cpp +++ b/src/network/access/qhttpnetworkreply.cpp @@ -162,7 +162,7 @@ qint64 QHttpNetworkReply::bytesAvailable() const { Q_D(const QHttpNetworkReply); if (d->connection) - return d->connection->d_func()->bytesAvailable(*this); + return d->connection->d_func()->uncompressedBytesAvailable(*this); else return -1; } @@ -172,7 +172,7 @@ QByteArray QHttpNetworkReply::read(qint64 maxSize) Q_D(QHttpNetworkReply); QByteArray data; if (d->connection) - d->connection->d_func()->read(*this, data, maxSize, false); + d->connection->d_func()->read(*this, data, maxSize); return data; } -- cgit v0.12 From e6647776249e0e3ac9bac38d72965aa87b607859 Mon Sep 17 00:00:00 2001 From: Kent Hansen Date: Thu, 25 Jun 2009 16:04:41 +0200 Subject: don't crash when QTextCodec::codecForUtfText() is passed -1 bytes It's possible that the function gets called with a bytearray of size -1 (for example, by QTextStreamPrivate::fillReadBuffer()). Since the size was erroneously cast to a uint, the subsequent comparison (arraySize > 3) succeeded and caused a crash. Reviewed-by: Denis Dzyubenko --- src/corelib/codecs/qtextcodec.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/corelib/codecs/qtextcodec.cpp b/src/corelib/codecs/qtextcodec.cpp index 32c6aef..d4e5d44 100644 --- a/src/corelib/codecs/qtextcodec.cpp +++ b/src/corelib/codecs/qtextcodec.cpp @@ -1560,7 +1560,7 @@ QTextCodec *QTextCodec::codecForHtml(const QByteArray &ba) */ QTextCodec *QTextCodec::codecForUtfText(const QByteArray &ba, QTextCodec *defaultCodec) { - const uint arraySize = ba.size(); + const int arraySize = ba.size(); if (arraySize > 3) { if ((uchar)ba[0] == 0x00 -- cgit v0.12 From 9d8f5dcb46f64ee2f5e205100b603f6d01f1381b Mon Sep 17 00:00:00 2001 From: Kent Hansen Date: Thu, 25 Jun 2009 16:27:30 +0200 Subject: have the QtScript print() function use qDebug() Makes it work with custom message handlers (qInstallMsgHandler()). Task-number: 233005 --- src/script/qscriptecmaglobal.cpp | 3 +-- tests/auto/qscriptengine/tst_qscriptengine.cpp | 28 ++++++++++++++++++++++++++ 2 files changed, 29 insertions(+), 2 deletions(-) diff --git a/src/script/qscriptecmaglobal.cpp b/src/script/qscriptecmaglobal.cpp index a7cb115..b756a27 100644 --- a/src/script/qscriptecmaglobal.cpp +++ b/src/script/qscriptecmaglobal.cpp @@ -305,8 +305,7 @@ public: } if (context->state() != QScriptContext::ExceptionState) { - QTextStream qout(stdout, QIODevice::WriteOnly); - qout << result << endl; + qDebug(qPrintable(result)); context->setReturnValue(eng->undefinedValue()); } #ifndef Q_SCRIPT_NO_EVENT_NOTIFY diff --git a/tests/auto/qscriptengine/tst_qscriptengine.cpp b/tests/auto/qscriptengine/tst_qscriptengine.cpp index b63236e..68df392 100644 --- a/tests/auto/qscriptengine/tst_qscriptengine.cpp +++ b/tests/auto/qscriptengine/tst_qscriptengine.cpp @@ -101,6 +101,7 @@ private slots: void automaticSemicolonInsertion(); void abortEvaluation(); void isEvaluating(); + void printFunctionWithCustomHandler(); void printThrowsException(); void errorConstructors(); void argumentsProperty(); @@ -2473,6 +2474,33 @@ void tst_QScriptEngine::isEvaluating() } } +static QtMsgType theMessageType; +static QString theMessage; + +static void myMsgHandler(QtMsgType type, const char *msg) +{ + theMessageType = type; + theMessage = QString::fromLatin1(msg); +} + +void tst_QScriptEngine::printFunctionWithCustomHandler() +{ + QScriptEngine eng; + QtMsgHandler oldHandler = qInstallMsgHandler(myMsgHandler); + QVERIFY(eng.globalObject().property("print").isFunction()); + theMessageType = QtSystemMsg; + QVERIFY(theMessage.isEmpty()); + QVERIFY(eng.evaluate("print('test')").isUndefined()); + QCOMPARE(theMessageType, QtDebugMsg); + QCOMPARE(theMessage, QString::fromLatin1("test")); + theMessageType = QtSystemMsg; + theMessage.clear(); + QVERIFY(eng.evaluate("print(3, true, 'little pigs')").isUndefined()); + QCOMPARE(theMessageType, QtDebugMsg); + QCOMPARE(theMessage, QString::fromLatin1("3 true little pigs")); + qInstallMsgHandler(oldHandler); +} + void tst_QScriptEngine::printThrowsException() { QScriptEngine eng; -- cgit v0.12 From b393abc9ce2e2a5396e655895fe653f9e06e355f Mon Sep 17 00:00:00 2001 From: Thierry Bastian Date: Thu, 25 Jun 2009 16:41:26 +0200 Subject: QMenu: Fixed geometry for actions with specific font Task-number: 256918 --- src/gui/widgets/qmenu.cpp | 10 +++++----- tests/auto/qmenu/tst_qmenu.cpp | 15 +++++++++++++++ 2 files changed, 20 insertions(+), 5 deletions(-) diff --git a/src/gui/widgets/qmenu.cpp b/src/gui/widgets/qmenu.cpp index fc55a2c..15eeb09 100644 --- a/src/gui/widgets/qmenu.cpp +++ b/src/gui/widgets/qmenu.cpp @@ -235,16 +235,15 @@ void QMenuPrivate::calcActionRects(QMap &actionRects, QListfont().resolve(q->font())); - QSize sz; - //let the style modify the above size.. QStyleOptionMenuItem opt; q->initStyleOption(&opt, action); opt.rect = q->rect(); + const QFontMetrics &fm = opt.fontMetrics; + QSize sz; if (QWidget *w = widgetItems.value(action)) { - sz=w->sizeHint().expandedTo(w->minimumSize()).expandedTo(w->minimumSizeHint()).boundedTo(w->maximumSize()); + sz = w->sizeHint().expandedTo(w->minimumSize()).expandedTo(w->minimumSizeHint()).boundedTo(w->maximumSize()); } else { //calc what I think the size is.. if (action->isSeparator()) { @@ -1178,7 +1177,8 @@ void QMenu::initStyleOption(QStyleOptionMenuItem *option, const QAction *action) else option->palette.setCurrentColorGroup(QPalette::Disabled); - option->font = action->font(); + option->font = action->font().resolve(font()); + option->fontMetrics = QFontMetrics(option->font); if (d->currentAction && d->currentAction == action && !d->currentAction->isSeparator()) { option->state |= QStyle::State_Selected diff --git a/tests/auto/qmenu/tst_qmenu.cpp b/tests/auto/qmenu/tst_qmenu.cpp index 2fb9b8b..e431961 100644 --- a/tests/auto/qmenu/tst_qmenu.cpp +++ b/tests/auto/qmenu/tst_qmenu.cpp @@ -93,6 +93,7 @@ private slots: void task242454_sizeHint(); void task176201_clear(); void task250673_activeMutliColumnSubMenuPosition(); + void task256918_setFont(); protected slots: void onActivated(QAction*); void onHighlighted(QAction*); @@ -713,5 +714,19 @@ void tst_QMenu::task250673_activeMutliColumnSubMenuPosition() const int subMenuOffset = main.style()->pixelMetric(QStyle::PM_SubMenuOverlap, 0, &main); QVERIFY((sub.geometry().left() - subMenuOffset + 5) < main.geometry().right()); } + + +void tst_QMenu::task256918_setFont() +{ + QMenu menu; + QAction *action = menu.addAction("foo"); + QFont f; + f.setPointSize(30); + action->setFont(f); + menu.show(); //ensures that the actiongeometry are calculated + QVERIFY(menu.actionGeometry(action).height() > f.pointSize()); +} + + QTEST_MAIN(tst_QMenu) #include "tst_qmenu.moc" -- cgit v0.12 From 3984253ac58e0cca1c0b94fad1549dd4e0e3c2e1 Mon Sep 17 00:00:00 2001 From: Markus Goetz Date: Thu, 25 Jun 2009 16:52:45 +0200 Subject: QNAM HTTP Code: Prepare for download performance improvements Change the QByteArray to a QRingBuffer to save re-allocation time. Reviewed-by: Thiago Macieira --- src/network/access/qhttpnetworkconnection.cpp | 20 +++++++++++++------- src/network/access/qhttpnetworkconnection_p.h | 1 + src/network/access/qhttpnetworkreply.cpp | 9 +++++++++ src/network/access/qhttpnetworkreply_p.h | 6 ++++-- 4 files changed, 27 insertions(+), 9 deletions(-) diff --git a/src/network/access/qhttpnetworkconnection.cpp b/src/network/access/qhttpnetworkconnection.cpp index 365ae8b..8409660 100644 --- a/src/network/access/qhttpnetworkconnection.cpp +++ b/src/network/access/qhttpnetworkconnection.cpp @@ -176,7 +176,8 @@ bool QHttpNetworkConnectionPrivate::isSocketReading(QAbstractSocket *socket) con void QHttpNetworkConnectionPrivate::appendUncompressedData(QHttpNetworkReply &reply, const QByteArray &fragment) { - reply.d_func()->responseData.append(fragment); + char *dst = reply.d_func()->responseData.reserve(fragment.size()); + qMemCopy(dst, fragment.constData(), fragment.size()); } void QHttpNetworkConnectionPrivate::appendCompressedData(QHttpNetworkReply &reply, const QByteArray &fragment) @@ -189,6 +190,11 @@ qint64 QHttpNetworkConnectionPrivate::uncompressedBytesAvailable(const QHttpNetw return reply.d_func()->responseData.size(); } +qint64 QHttpNetworkConnectionPrivate::uncompressedBytesAvailableNextBlock(const QHttpNetworkReply &reply) const +{ + return reply.d_func()->responseData.nextDataBlockSize(); +} + qint64 QHttpNetworkConnectionPrivate::compressedBytesAvailable(const QHttpNetworkReply &reply) const { return reply.d_func()->compressedData.size(); @@ -196,15 +202,15 @@ qint64 QHttpNetworkConnectionPrivate::compressedBytesAvailable(const QHttpNetwor qint64 QHttpNetworkConnectionPrivate::read(QHttpNetworkReply &reply, QByteArray &data, qint64 maxSize) { - QByteArray *ba = &reply.d_func()->responseData; - if (maxSize == -1 || maxSize >= ba->size()) { + QRingBuffer *rb = &reply.d_func()->responseData; + if (maxSize == -1 || maxSize >= rb->size()) { // read the whole data - data = *ba; - ba->clear(); + data = rb->readAll(); + rb->clear(); } else { // read only the requested length - data = ba->mid(0, maxSize); - ba->remove(0, maxSize); + data.resize(maxSize); + rb->read(data.data(), maxSize); } return data.size(); } diff --git a/src/network/access/qhttpnetworkconnection_p.h b/src/network/access/qhttpnetworkconnection_p.h index bc4d948..3eb8ffe 100644 --- a/src/network/access/qhttpnetworkconnection_p.h +++ b/src/network/access/qhttpnetworkconnection_p.h @@ -258,6 +258,7 @@ public: void appendCompressedData(QHttpNetworkReply &reply, const QByteArray &fragment); qint64 uncompressedBytesAvailable(const QHttpNetworkReply &reply) const; + qint64 uncompressedBytesAvailableNextBlock(const QHttpNetworkReply &reply) const; qint64 compressedBytesAvailable(const QHttpNetworkReply &reply) const; qint64 read(QHttpNetworkReply &reply, QByteArray &data, qint64 maxSize); diff --git a/src/network/access/qhttpnetworkreply.cpp b/src/network/access/qhttpnetworkreply.cpp index 47fb6d1..202bdea 100644 --- a/src/network/access/qhttpnetworkreply.cpp +++ b/src/network/access/qhttpnetworkreply.cpp @@ -167,6 +167,15 @@ qint64 QHttpNetworkReply::bytesAvailable() const return -1; } +qint64 QHttpNetworkReply::bytesAvailableNextBlock() const +{ + Q_D(const QHttpNetworkReply); + if (d->connection) + return d->connection->d_func()->uncompressedBytesAvailableNextBlock(*this); + else + return -1; +} + QByteArray QHttpNetworkReply::read(qint64 maxSize) { Q_D(QHttpNetworkReply); diff --git a/src/network/access/qhttpnetworkreply_p.h b/src/network/access/qhttpnetworkreply_p.h index 08bd886..69c9158 100644 --- a/src/network/access/qhttpnetworkreply_p.h +++ b/src/network/access/qhttpnetworkreply_p.h @@ -79,6 +79,7 @@ static const unsigned char gz_magic[2] = {0x1f, 0x8b}; // gzip magic header #include #include #include +#include QT_BEGIN_NAMESPACE @@ -120,6 +121,7 @@ public: QString reasonPhrase() const; qint64 bytesAvailable() const; + qint64 bytesAvailableNextBlock() const; QByteArray read(qint64 maxSize = -1); bool isFinished() const; @@ -193,7 +195,7 @@ public: qint64 bodyLength; qint64 contentRead; qint64 totalProgress; - QByteArray fragment; + QByteArray fragment; // used for header, status, chunk header etc, not for reply data qint64 currentChunkSize; qint64 currentChunkRead; QPointer connection; @@ -204,7 +206,7 @@ public: #endif bool autoDecompress; - QByteArray responseData; // uncompressed body + QRingBuffer responseData; // uncompressed body QByteArray compressedData; // compressed body (temporary) bool requestIsPrepared; }; -- cgit v0.12 From 47c9e7b1b3551ff6dbe71590461a45ae398a9501 Mon Sep 17 00:00:00 2001 From: Kent Hansen Date: Thu, 25 Jun 2009 17:25:48 +0200 Subject: make it possible to support queued connections in qtscript This change doesn't actually add public API for it, but makes it trivial to add. On the C++ side, qScriptConnect() would get an overload that takes an additional argument, the connection type (d'oh, it should have had a default argument to begin with!). On the script side, it's a bit more tricky to "overload" the existing connect(), since it's already "overloaded" (can have either one or two parameters). Plus, I'd like connect() to be able to support bind-like functionality so you can pass additional arguments to it that will be passed to the signal handler at signal emission time. Oh well, we'll see. --- src/script/qscriptecmafunction.cpp | 2 +- src/script/qscriptengine.cpp | 3 ++- src/script/qscriptengine_p.cpp | 15 +++++++++------ src/script/qscriptenginefwd_p.h | 9 ++++++--- src/script/qscriptextqobject.cpp | 13 ++++++++----- src/script/qscriptextqobject_p.h | 3 ++- 6 files changed, 28 insertions(+), 17 deletions(-) diff --git a/src/script/qscriptecmafunction.cpp b/src/script/qscriptecmafunction.cpp index 87b0639..0bb5f12 100644 --- a/src/script/qscriptecmafunction.cpp +++ b/src/script/qscriptecmafunction.cpp @@ -436,7 +436,7 @@ QScriptValueImpl Function::method_connect(QScriptContextPrivate *context, QScrip QLatin1String("Function.prototype.connect: target is not a function")); } - bool ok = eng->scriptConnect(self, receiver, slot); + bool ok = eng->scriptConnect(self, receiver, slot, Qt::AutoConnection); if (!ok) { return context->throwError( QString::fromLatin1("Function.prototype.connect: failed to connect to %0::%1") diff --git a/src/script/qscriptengine.cpp b/src/script/qscriptengine.cpp index de8bd8d..de78403 100644 --- a/src/script/qscriptengine.cpp +++ b/src/script/qscriptengine.cpp @@ -1616,7 +1616,8 @@ bool qScriptConnect(QObject *sender, const char *signal, QScriptEnginePrivate *eng_p = QScriptEnginePrivate::get(function.engine()); return eng_p->scriptConnect(sender, signal, eng_p->toImpl(receiver), - eng_p->toImpl(function)); + eng_p->toImpl(function), + Qt::AutoConnection); } /*! diff --git a/src/script/qscriptengine_p.cpp b/src/script/qscriptengine_p.cpp index 0a238bc..ffb5a27 100644 --- a/src/script/qscriptengine_p.cpp +++ b/src/script/qscriptengine_p.cpp @@ -2312,7 +2312,8 @@ void QScriptEnginePrivate::deletePendingQObjects() bool QScriptEnginePrivate::scriptConnect(QObject *sender, const char *signal, const QScriptValueImpl &receiver, - const QScriptValueImpl &function) + const QScriptValueImpl &function, + Qt::ConnectionType type) { Q_ASSERT(sender); Q_ASSERT(signal); @@ -2320,7 +2321,7 @@ bool QScriptEnginePrivate::scriptConnect(QObject *sender, const char *signal, int index = meta->indexOfSignal(QMetaObject::normalizedSignature(signal+1)); if (index == -1) return false; - return scriptConnect(sender, index, receiver, function); + return scriptConnect(sender, index, receiver, function, /*wrapper=*/QScriptValueImpl(), type); } bool QScriptEnginePrivate::scriptDisconnect(QObject *sender, const char *signal, @@ -2339,10 +2340,11 @@ bool QScriptEnginePrivate::scriptDisconnect(QObject *sender, const char *signal, bool QScriptEnginePrivate::scriptConnect(QObject *sender, int signalIndex, const QScriptValueImpl &receiver, const QScriptValueImpl &function, - const QScriptValueImpl &senderWrapper) + const QScriptValueImpl &senderWrapper, + Qt::ConnectionType type) { QScriptQObjectData *data = qobjectData(sender); - return data->addSignalHandler(sender, signalIndex, receiver, function, senderWrapper); + return data->addSignalHandler(sender, signalIndex, receiver, function, senderWrapper, type); } bool QScriptEnginePrivate::scriptDisconnect(QObject *sender, int signalIndex, @@ -2357,11 +2359,12 @@ bool QScriptEnginePrivate::scriptDisconnect(QObject *sender, int signalIndex, bool QScriptEnginePrivate::scriptConnect(const QScriptValueImpl &signal, const QScriptValueImpl &receiver, - const QScriptValueImpl &function) + const QScriptValueImpl &function, + Qt::ConnectionType type) { QScript::QtFunction *fun = static_cast(signal.toFunction()); int index = fun->mostGeneralMethod(); - return scriptConnect(fun->qobject(), index, receiver, function, fun->object()); + return scriptConnect(fun->qobject(), index, receiver, function, fun->object(), type); } bool QScriptEnginePrivate::scriptDisconnect(const QScriptValueImpl &signal, diff --git a/src/script/qscriptenginefwd_p.h b/src/script/qscriptenginefwd_p.h index 11cd839..62942a5 100644 --- a/src/script/qscriptenginefwd_p.h +++ b/src/script/qscriptenginefwd_p.h @@ -385,7 +385,8 @@ public: bool scriptConnect(QObject *sender, const char *signal, const QScriptValueImpl &receiver, - const QScriptValueImpl &function); + const QScriptValueImpl &function, + Qt::ConnectionType type); bool scriptDisconnect(QObject *sender, const char *signal, const QScriptValueImpl &receiver, const QScriptValueImpl &function); @@ -393,14 +394,16 @@ public: bool scriptConnect(QObject *sender, int index, const QScriptValueImpl &receiver, const QScriptValueImpl &function, - const QScriptValueImpl &senderWrapper = QScriptValueImpl()); + const QScriptValueImpl &senderWrapper, + Qt::ConnectionType type); bool scriptDisconnect(QObject *sender, int index, const QScriptValueImpl &receiver, const QScriptValueImpl &function); bool scriptConnect(const QScriptValueImpl &signal, const QScriptValueImpl &receiver, - const QScriptValueImpl &function); + const QScriptValueImpl &function, + Qt::ConnectionType type); bool scriptDisconnect(const QScriptValueImpl &signal, const QScriptValueImpl &receiver, const QScriptValueImpl &function); diff --git a/src/script/qscriptextqobject.cpp b/src/script/qscriptextqobject.cpp index 00963a7..a3cb4e6 100644 --- a/src/script/qscriptextqobject.cpp +++ b/src/script/qscriptextqobject.cpp @@ -1420,7 +1420,8 @@ public: bool addSignalHandler(QObject *sender, int signalIndex, const QScriptValueImpl &receiver, const QScriptValueImpl &slot, - const QScriptValueImpl &senderWrapper = QScriptValueImpl()); + const QScriptValueImpl &senderWrapper, + Qt::ConnectionType type); bool removeSignalHandler( QObject *sender, int signalIndex, const QScriptValueImpl &receiver, @@ -1741,13 +1742,14 @@ void QScript::QObjectConnectionManager::mark(int generation) bool QScript::QObjectConnectionManager::addSignalHandler( QObject *sender, int signalIndex, const QScriptValueImpl &receiver, - const QScriptValueImpl &function, const QScriptValueImpl &senderWrapper) + const QScriptValueImpl &function, const QScriptValueImpl &senderWrapper, + Qt::ConnectionType type) { if (connections.size() <= signalIndex) connections.resize(signalIndex+1); QVector &cs = connections[signalIndex]; int absSlotIndex = m_slotCounter + metaObject()->methodOffset(); - bool ok = QMetaObject::connect(sender, signalIndex, this, absSlotIndex); + bool ok = QMetaObject::connect(sender, signalIndex, this, absSlotIndex, type); if (ok) { cs.append(QScript::QObjectConnection(m_slotCounter++, receiver, function, senderWrapper)); QMetaMethod signal = sender->metaObject()->method(signalIndex); @@ -2176,12 +2178,13 @@ bool QScriptQObjectData::addSignalHandler(QObject *sender, int signalIndex, const QScriptValueImpl &receiver, const QScriptValueImpl &slot, - const QScriptValueImpl &senderWrapper) + const QScriptValueImpl &senderWrapper, + Qt::ConnectionType type) { if (!m_connectionManager) m_connectionManager = new QScript::QObjectConnectionManager(); return m_connectionManager->addSignalHandler( - sender, signalIndex, receiver, slot, senderWrapper); + sender, signalIndex, receiver, slot, senderWrapper, type); } bool QScriptQObjectData::removeSignalHandler(QObject *sender, diff --git a/src/script/qscriptextqobject_p.h b/src/script/qscriptextqobject_p.h index 764644f..8f10823 100644 --- a/src/script/qscriptextqobject_p.h +++ b/src/script/qscriptextqobject_p.h @@ -216,7 +216,8 @@ public: int signalIndex, const QScriptValueImpl &receiver, const QScriptValueImpl &slot, - const QScriptValueImpl &senderWrapper = QScriptValueImpl()); + const QScriptValueImpl &senderWrapper, + Qt::ConnectionType type); bool removeSignalHandler(QObject *sender, int signalIndex, const QScriptValueImpl &receiver, -- cgit v0.12 From db24e82b6b74be303492f186a45d784fcd84fdc6 Mon Sep 17 00:00:00 2001 From: Jens Bache-Wiig Date: Thu, 25 Jun 2009 16:35:55 +0200 Subject: Improved support for DPI on Mac and Vista/7 This significantly improves the support for higher DPI-values on these platforms by ensuring that common pixelmetrics are scaled accordingly. In addition we mark all Qt apps as DPI-aware on Windows 7 by calling SetProcessDPIAware. We also changed the way we draw pixmaps on the mac paintengine when using dpi scaling > 1 to ensure smooth pixmap scaling. Reviewed-by: nrc Task-id: 242417 --- src/gui/kernel/qapplication_win.cpp | 9 ++++ src/gui/painting/qpaintengine_mac.cpp | 9 +++- src/gui/styles/qcommonstyle.cpp | 80 +++++++++++++++++------------------ src/gui/styles/qstylehelper.cpp | 27 +++++++++++- src/gui/styles/qstylehelper_p.h | 1 + src/gui/styles/qwindowsstyle.cpp | 26 +++++++----- src/gui/styles/qwindowsvistastyle.cpp | 79 ++++++++++++++++++++++++++-------- src/gui/styles/qwindowsxpstyle.cpp | 12 +++--- 8 files changed, 166 insertions(+), 77 deletions(-) diff --git a/src/gui/kernel/qapplication_win.cpp b/src/gui/kernel/qapplication_win.cpp index 324fac7..a690ffd 100644 --- a/src/gui/kernel/qapplication_win.cpp +++ b/src/gui/kernel/qapplication_win.cpp @@ -720,7 +720,11 @@ void QApplicationPrivate::initializeWidgetPaletteHash() typedef BOOL (WINAPI *PtrUpdateLayeredWindow)(HWND hwnd, HDC hdcDst, const POINT *pptDst, const SIZE *psize, HDC hdcSrc, const POINT *pptSrc, COLORREF crKey, const Q_BLENDFUNCTION *pblend, DWORD dwflags); + +typedef BOOL (WINAPI *PtrSetProcessDPIAware) (VOID); + static PtrUpdateLayeredWindow ptrUpdateLayeredWindow = 0; +static PtrSetProcessDPIAware ptrSetProcessDPIAware = 0; static BOOL WINAPI qt_updateLayeredWindowIndirect(HWND hwnd, const Q_UPDATELAYEREDWINDOWINFO *info) { @@ -846,6 +850,11 @@ void qt_init(QApplicationPrivate *priv, int) if (ptrUpdateLayeredWindow && !ptrUpdateLayeredWindowIndirect) ptrUpdateLayeredWindowIndirect = qt_updateLayeredWindowIndirect; + + // Notify Vista and Windows 7 that we support highter DPI settings + if (ptrSetProcessDPIAware = (PtrSetProcessDPIAware) + QLibrary::resolve(QLatin1String("user32"), "SetProcessDPIAware")) + ptrSetProcessDPIAware(); #endif } diff --git a/src/gui/painting/qpaintengine_mac.cpp b/src/gui/painting/qpaintengine_mac.cpp index 793460f..f5f1bba 100644 --- a/src/gui/painting/qpaintengine_mac.cpp +++ b/src/gui/painting/qpaintengine_mac.cpp @@ -1381,8 +1381,13 @@ QCoreGraphicsPaintEngine::updateRenderHints(QPainter::RenderHints hints) { Q_D(QCoreGraphicsPaintEngine); CGContextSetShouldAntialias(d->hd, hints & QPainter::Antialiasing); - CGContextSetInterpolationQuality(d->hd, (hints & QPainter::SmoothPixmapTransform) ? - kCGInterpolationHigh : kCGInterpolationNone); + static const CGFloat ScaleFactor = qt_mac_get_scalefactor(); + if (ScaleFactor > 1.) { + CGContextSetInterpolationQuality(d->hd, kCGInterpolationHigh); + } else { + CGContextSetInterpolationQuality(d->hd, (hints & QPainter::SmoothPixmapTransform) ? + kCGInterpolationHigh : kCGInterpolationNone); + } CGContextSetShouldSmoothFonts(d->hd, hints & QPainter::TextAntialiasing); } diff --git a/src/gui/styles/qcommonstyle.cpp b/src/gui/styles/qcommonstyle.cpp index ed3bdb5..7b8b75e 100644 --- a/src/gui/styles/qcommonstyle.cpp +++ b/src/gui/styles/qcommonstyle.cpp @@ -4535,17 +4535,17 @@ int QCommonStyle::pixelMetric(PixelMetric m, const QStyleOption *opt, const QWid ret = 0; break; case PM_DialogButtonsSeparator: - ret = 5; + ret = int(QStyleHelper::dpiScaled(5.)); break; case PM_DialogButtonsButtonWidth: - ret = 70; + ret = int(QStyleHelper::dpiScaled(70.)); break; case PM_DialogButtonsButtonHeight: - ret = 30; + ret = int(QStyleHelper::dpiScaled(30.)); break; case PM_CheckListControllerSize: case PM_CheckListButtonSize: - ret = 16; + ret = int(QStyleHelper::dpiScaled(16.)); break; case PM_TitleBarHeight: { if (const QStyleOptionTitleBar *tb = qstyleoption_cast(opt)) { @@ -4553,26 +4553,26 @@ int QCommonStyle::pixelMetric(PixelMetric m, const QStyleOption *opt, const QWid ret = qMax(widget ? widget->fontMetrics().lineSpacing() : opt->fontMetrics.lineSpacing(), 16); #ifndef QT_NO_DOCKWIDGET } else if (qobject_cast(widget)) { - ret = qMax(widget->fontMetrics().lineSpacing(), 13); + ret = qMax(widget->fontMetrics().lineSpacing(), int(QStyleHelper::dpiScaled(13))); #endif } else { ret = qMax(widget ? widget->fontMetrics().lineSpacing() : opt->fontMetrics.lineSpacing(), 18); } } else { - ret = 18; + ret = int(QStyleHelper::dpiScaled(18.)); } break; } case PM_ScrollBarSliderMin: - ret = 9; + ret = int(QStyleHelper::dpiScaled(9.)); break; case PM_ButtonMargin: - ret = 6; + ret = int(QStyleHelper::dpiScaled(6.)); break; case PM_DockWidgetTitleBarButtonMargin: - ret = 2; + ret = int(QStyleHelper::dpiScaled(2.)); break; case PM_ButtonDefaultIndicator: @@ -4580,7 +4580,7 @@ int QCommonStyle::pixelMetric(PixelMetric m, const QStyleOption *opt, const QWid break; case PM_MenuButtonIndicator: - ret = 12; + ret = int(QStyleHelper::dpiScaled(12.)); break; case PM_ButtonShiftHorizontal: @@ -4599,11 +4599,11 @@ int QCommonStyle::pixelMetric(PixelMetric m, const QStyleOption *opt, const QWid break; case PM_MdiSubWindowFrameWidth: - ret = 4; + ret = int(QStyleHelper::dpiScaled(4.)); break; case PM_MdiSubWindowMinimizedWidth: - ret = 196; + ret = int(QStyleHelper::dpiScaled(196.)); break; #ifndef QT_NO_SCROLLBAR @@ -4614,7 +4614,7 @@ int QCommonStyle::pixelMetric(PixelMetric m, const QStyleOption *opt, const QWid : QApplication::globalStrut().width(); ret = qMax(16, s); } else { - ret = 16; + ret = int(QStyleHelper::dpiScaled(16.)); } break; #endif @@ -4624,7 +4624,7 @@ int QCommonStyle::pixelMetric(PixelMetric m, const QStyleOption *opt, const QWid #ifndef QT_NO_SLIDER case PM_SliderThickness: - ret = 16; + ret = int(QStyleHelper::dpiScaled(16.)); break; case PM_SliderTickmarkOffset: @@ -4658,11 +4658,11 @@ int QCommonStyle::pixelMetric(PixelMetric m, const QStyleOption *opt, const QWid #endif // QT_NO_SLIDER #ifndef QT_NO_DOCKWIDGET case PM_DockWidgetSeparatorExtent: - ret = 6; + ret = int(QStyleHelper::dpiScaled(6.)); break; case PM_DockWidgetHandleExtent: - ret = 8; + ret = int(QStyleHelper::dpiScaled(8.)); break; case PM_DockWidgetTitleMargin: ret = 0; @@ -4691,19 +4691,19 @@ int QCommonStyle::pixelMetric(PixelMetric m, const QStyleOption *opt, const QWid break; case PM_ToolBarItemSpacing: - ret = 4; + ret = int(QStyleHelper::dpiScaled(4.)); break; case PM_ToolBarHandleExtent: - ret = 8; + ret = int(QStyleHelper::dpiScaled(8.)); break; case PM_ToolBarSeparatorExtent: - ret = 6; + ret = int(QStyleHelper::dpiScaled(6.)); break; case PM_ToolBarExtensionExtent: - ret = 12; + ret = int(QStyleHelper::dpiScaled(12.)); break; #endif // QT_NO_TOOLBAR @@ -4713,7 +4713,7 @@ int QCommonStyle::pixelMetric(PixelMetric m, const QStyleOption *opt, const QWid break; case PM_TabBarTabHSpace: - ret = 24; + ret = int(QStyleHelper::dpiScaled(24.)); break; case PM_TabBarTabShiftHorizontal: @@ -4742,27 +4742,27 @@ int QCommonStyle::pixelMetric(PixelMetric m, const QStyleOption *opt, const QWid break; case PM_IndicatorWidth: - ret = 13; + ret = int(QStyleHelper::dpiScaled(13.)); break; case PM_IndicatorHeight: - ret = 13; + ret = int(QStyleHelper::dpiScaled(13.)); break; case PM_ExclusiveIndicatorWidth: - ret = 12; + ret = int(QStyleHelper::dpiScaled(12.)); break; case PM_ExclusiveIndicatorHeight: - ret = 12; + ret = int(QStyleHelper::dpiScaled(12.)); break; case PM_MenuTearoffHeight: - ret = 10; + ret = int(QStyleHelper::dpiScaled(10.)); break; case PM_MenuScrollerHeight: - ret = 10; + ret = int(QStyleHelper::dpiScaled(10.)); break; case PM_MenuDesktopFrameWidth: @@ -4772,16 +4772,16 @@ int QCommonStyle::pixelMetric(PixelMetric m, const QStyleOption *opt, const QWid break; case PM_HeaderMargin: - ret = 4; + ret = int(QStyleHelper::dpiScaled(4.)); break; case PM_HeaderMarkSize: - ret = 32; + ret = int(QStyleHelper::dpiScaled(32.)); break; case PM_HeaderGripMargin: - ret = 4; + ret = int(QStyleHelper::dpiScaled(4.)); break; case PM_TabBarScrollButtonWidth: - ret = 16; + ret = int(QStyleHelper::dpiScaled(16.)); break; case PM_LayoutLeftMargin: case PM_LayoutTopMargin: @@ -4803,13 +4803,13 @@ int QCommonStyle::pixelMetric(PixelMetric m, const QStyleOption *opt, const QWid break; case PM_DefaultTopLevelMargin: - ret = 11; + ret = int(QStyleHelper::dpiScaled(11.)); break; case PM_DefaultChildMargin: - ret = 9; + ret = int(QStyleHelper::dpiScaled(9.)); break; case PM_DefaultLayoutSpacing: - ret = 6; + ret = int(QStyleHelper::dpiScaled(6.)); break; case PM_TabBarIconSize: @@ -4820,14 +4820,14 @@ int QCommonStyle::pixelMetric(PixelMetric m, const QStyleOption *opt, const QWid case PM_ButtonIconSize: case PM_SmallIconSize: - ret = 16; + ret = int(QStyleHelper::dpiScaled(16.)); break; case PM_IconViewIconSize: ret = proxy()->pixelMetric(PM_LargeIconSize, opt, widget); break; case PM_LargeIconSize: - ret = 32; + ret = int(QStyleHelper::dpiScaled(32.)); break; case PM_ToolTipLabelFrameWidth: @@ -4835,13 +4835,13 @@ int QCommonStyle::pixelMetric(PixelMetric m, const QStyleOption *opt, const QWid break; case PM_CheckBoxLabelSpacing: case PM_RadioButtonLabelSpacing: - ret = 6; + ret = int(QStyleHelper::dpiScaled(6.)); break; case PM_SizeGripSize: - ret = 13; + ret = int(QStyleHelper::dpiScaled(13.)); break; case PM_MessageBoxIconSize: - ret = 32; + ret = int(QStyleHelper::dpiScaled(32.)); break; case PM_TextCursorWidth: ret = 1; @@ -4851,7 +4851,7 @@ int QCommonStyle::pixelMetric(PixelMetric m, const QStyleOption *opt, const QWid break; case PM_TabCloseIndicatorWidth: case PM_TabCloseIndicatorHeight: - ret = 16; + ret = int(QStyleHelper::dpiScaled(16.)); break; case PM_ScrollView_ScrollBarSpacing: ret = 2 * proxy()->pixelMetric(PM_DefaultFrameWidth, opt, widget); diff --git a/src/gui/styles/qstylehelper.cpp b/src/gui/styles/qstylehelper.cpp index 997bd68..f9010e8 100644 --- a/src/gui/styles/qstylehelper.cpp +++ b/src/gui/styles/qstylehelper.cpp @@ -48,6 +48,12 @@ #include #include +#if defined(Q_WS_WIN) +#include "qt_windows.h" +#elif defined(Q_WS_MAC) +#include +#endif + QT_BEGIN_NAMESPACE namespace QStyleHelper { @@ -72,6 +78,26 @@ QString uniqueName(const QString &key, const QStyleOption *option, const QSize & return tmp; } +qreal dpiScaled(qreal value) +{ + static qreal scale = -1; + if (scale < 0) { + scale = 1.0; +#if defined(Q_WS_WIN) + { + HDC hdcScreen = GetDC(0); + int dpi = GetDeviceCaps(hdcScreen, LOGPIXELSX); + ReleaseDC(0, hdcScreen); + scale = dpi/96.0; + } +#elif defined(Q_WS_MAC) + scale = qt_mac_get_scalefactor(); +#endif + } + return value * scale; +} + + #ifndef QT_NO_DIAL int calcBigLineSize(int radius) @@ -178,7 +204,6 @@ QPolygonF calcLines(const QStyleOptionSlider *dial) return poly; } - // This will draw a nice and shiny QDial for us. We don't want // all the shinyness in QWindowsStyle, hence we place it here diff --git a/src/gui/styles/qstylehelper_p.h b/src/gui/styles/qstylehelper_p.h index 7099e87..cac88e2 100644 --- a/src/gui/styles/qstylehelper_p.h +++ b/src/gui/styles/qstylehelper_p.h @@ -67,6 +67,7 @@ class QStyleOption; namespace QStyleHelper { QString uniqueName(const QString &key, const QStyleOption *option, const QSize &size); + qreal dpiScaled(qreal value); #ifndef QT_NO_DIAL qreal angle(const QPointF &p1, const QPointF &p2); QPolygonF calcLines(const QStyleOptionSlider *dial); diff --git a/src/gui/styles/qwindowsstyle.cpp b/src/gui/styles/qwindowsstyle.cpp index 39743b0..997c2ce 100644 --- a/src/gui/styles/qwindowsstyle.cpp +++ b/src/gui/styles/qwindowsstyle.cpp @@ -42,6 +42,7 @@ #include "qwindowsstyle.h" #include "qwindowsstyle_p.h" #include +#include #if !defined(QT_NO_STYLE_WINDOWS) || defined(QT_PLUGIN) @@ -405,7 +406,7 @@ int QWindowsStyle::pixelMetric(PixelMetric pm, const QStyleOption *opt, const QW #ifndef QT_NO_SLIDER case PM_SliderLength: - ret = 11; + ret = int(QStyleHelper::dpiScaled(11.)); break; // Returns the number of pixels to use for the business part of the @@ -453,11 +454,11 @@ int QWindowsStyle::pixelMetric(PixelMetric pm, const QStyleOption *opt, const QW break; case PM_SmallIconSize: - ret = 16; + ret = int(QStyleHelper::dpiScaled(16.)); break; case PM_LargeIconSize: - ret = 32; + ret = int(QStyleHelper::dpiScaled(32.)); break; case PM_IconViewIconSize: @@ -465,13 +466,13 @@ int QWindowsStyle::pixelMetric(PixelMetric pm, const QStyleOption *opt, const QW break; case PM_ToolBarIconSize: - ret = 24; + ret = int(QStyleHelper::dpiScaled(24.)); break; case PM_DockWidgetTitleMargin: - ret = 2; + ret = int(QStyleHelper::dpiScaled(2.)); break; case PM_DockWidgetTitleBarButtonMargin: - ret = 4; + ret = int(QStyleHelper::dpiScaled(4.)); break; #if defined(Q_WS_WIN) case PM_DockWidgetFrameWidth: @@ -553,7 +554,7 @@ int QWindowsStyle::pixelMetric(PixelMetric pm, const QStyleOption *opt, const QW ret = 0; break; case PM_ToolBarHandleExtent: - ret = 10; + ret = int(QStyleHelper::dpiScaled(10.)); break; default: ret = QCommonStyle::pixelMetric(pm, opt, widget); @@ -3200,11 +3201,14 @@ QSize QWindowsStyle::sizeFromContents(ContentsType ct, const QStyleOption *opt, int defwidth = 0; if (btn->features & QStyleOptionButton::AutoDefaultButton) defwidth = 2 * proxy()->pixelMetric(PM_ButtonDefaultIndicator, btn, widget); + int minwidth = int(QStyleHelper::dpiScaled(75.)); + int minheight = int(QStyleHelper::dpiScaled(23.)); + #ifndef QT_QWS_SMALL_PUSHBUTTON - if (w < 75 + defwidth && !btn->text.isEmpty()) - w = 75 + defwidth; - if (h < 23 + defwidth) - h = 23 + defwidth; + if (w < minwidth + defwidth && !btn->text.isEmpty()) + w = minwidth + defwidth; + if (h < minheight + defwidth) + h = minheight + defwidth; #endif sz = QSize(w, h); } diff --git a/src/gui/styles/qwindowsvistastyle.cpp b/src/gui/styles/qwindowsvistastyle.cpp index 7a75a7d..5f0f053 100644 --- a/src/gui/styles/qwindowsvistastyle.cpp +++ b/src/gui/styles/qwindowsvistastyle.cpp @@ -41,6 +41,7 @@ #include "qwindowsvistastyle.h" #include "qwindowsvistastyle_p.h" +#include #if !defined(QT_NO_STYLE_WINDOWSVISTA) || defined(QT_PLUGIN) @@ -487,7 +488,12 @@ void QWindowsVistaStyle::drawPrimitive(PrimitiveElement element, const QStyleOpt case PE_IndicatorBranch: { XPThemeData theme(d->treeViewHelper(), painter, QLatin1String("TREEVIEW")); - static const int decoration_size = 16; + static int decoration_size = 0; + if (theme.isValid() && !decoration_size) { + SIZE size; + pGetThemePartSize(theme.handle(), 0, TVP_HOTGLYPH, GLPS_OPENED, 0, TS_TRUE, &size); + decoration_size = qMax(size.cx, size.cy); + } int mid_h = option->rect.x() + option->rect.width() / 2; int mid_v = option->rect.y() + option->rect.height() / 2; int bef_h = mid_h; @@ -535,17 +541,6 @@ void QWindowsVistaStyle::drawPrimitive(PrimitiveElement element, const QStyleOpt } break; - case PE_IndicatorToolBarHandle: - { - XPThemeData theme; - if (option->state & State_Horizontal) - theme = XPThemeData(widget, painter, QLatin1String("REBAR"), RP_GRIPPER, ETS_NORMAL, option->rect.adjusted(0, 1, -2, -2)); - else - theme = XPThemeData(widget, painter, QLatin1String("REBAR"), RP_GRIPPERVERT, ETS_NORMAL, option->rect.adjusted(0, 1, -2, -2)); - d->drawBackground(theme); - } - break; - case PE_FrameMenu: { int stateId = option->state & State_Active ? MB_ACTIVE : MB_INACTIVE; @@ -694,6 +689,24 @@ void QWindowsVistaStyle::drawPrimitive(PrimitiveElement element, const QStyleOpt } break; + case PE_IndicatorToolBarHandle: + { + XPThemeData theme; + QRect rect; + if (option->state & State_Horizontal) { + theme = XPThemeData(widget, painter, QLatin1String("REBAR"), RP_GRIPPER, ETS_NORMAL, option->rect.adjusted(0, 1, -2, -2)); + rect = option->rect.adjusted(0, 1, 0, -2); + rect.setWidth(4); + } else { + theme = XPThemeData(widget, painter, QLatin1String("REBAR"), RP_GRIPPERVERT, ETS_NORMAL, option->rect.adjusted(0, 1, -2, -2)); + rect = option->rect.adjusted(1, 0, -1, 0); + rect.setHeight(4); + } + theme.rect = rect; + d->drawBackground(theme); + } + break; + case PE_IndicatorToolBarSeparator: { QPen pen = painter->pen(); @@ -1230,7 +1243,15 @@ void QWindowsVistaStyle::drawControl(ControlElement element, const QStyleOption case CE_MenuItem: if (const QStyleOptionMenuItem *menuitem = qstyleoption_cast(option)) { // windows always has a check column, regardless whether we have an icon or not - int checkcol = qMax(menuitem->maxIconWidth, 28); + int checkcol = 28; + { + SIZE size; + MARGINS margins; + XPThemeData theme(widget, 0, QLatin1String("MENU"), MENU_POPUPCHECKBACKGROUND, MBI_HOT); + pGetThemePartSize(theme.handle(), NULL, MENU_POPUPCHECK, 0, NULL,TS_TRUE, &size); + pGetThemeMargins(theme.handle(), NULL, MENU_POPUPCHECK, 0, TMT_CONTENTMARGINS, NULL, &margins); + checkcol = qMax(menuitem->maxIconWidth, int(6 + size.cx + margins.cxLeftWidth + margins.cxRightWidth)); + } QColor darkLine = option->palette.background().color().darker(108); QColor lightLine = option->palette.background().color().lighter(107); QRect rect = option->rect; @@ -1275,8 +1296,23 @@ void QWindowsVistaStyle::drawControl(ControlElement element, const QStyleOption if (checked) { XPThemeData theme(widget, painter, QLatin1String("MENU"), MENU_POPUPCHECKBACKGROUND, menuitem->icon.isNull() ? MBI_HOT : MBI_PUSHED, vCheckRect); + SIZE size; + MARGINS margins; + pGetThemePartSize(theme.handle(), NULL, MENU_POPUPCHECK, 0, NULL,TS_TRUE, &size); + pGetThemeMargins(theme.handle(), NULL, MENU_POPUPCHECK, 0, + TMT_CONTENTMARGINS, NULL, &margins); + QRect checkRect(0, 0, size.cx + margins.cxLeftWidth + margins.cxRightWidth , + size.cy + margins.cyBottomHeight + margins.cyTopHeight); + checkRect.moveCenter(vCheckRect.center()); + theme.rect = checkRect; + d->drawBackground(theme); + if (menuitem->icon.isNull()) { + checkRect = QRect(0, 0, size.cx, size.cy); + checkRect.moveCenter(theme.rect.center()); + theme.rect = checkRect; + theme.partId = MENU_POPUPCHECK; bool bullet = menuitem->checkType & QStyleOptionMenuItem::Exclusive; if (dis) @@ -1926,9 +1962,18 @@ QSize QWindowsVistaStyle::sizeFromContents(ContentsType type, const QStyleOption return sz; case CT_MenuItem: sz = QWindowsXPStyle::sizeFromContents(type, option, size, widget); - sz.rwidth() += 28; + int minimumHeight; + { + SIZE size; + MARGINS margins; + XPThemeData theme(widget, 0, QLatin1String("MENU"), MENU_POPUPCHECKBACKGROUND, MBI_HOT); + pGetThemePartSize(theme.handle(), NULL, MENU_POPUPCHECK, 0, NULL,TS_TRUE, &size); + pGetThemeMargins(theme.handle(), NULL, MENU_POPUPCHECK, 0, TMT_CONTENTMARGINS, NULL, &margins); + minimumHeight = qMax(size.cy + margins.cyBottomHeight+ margins.cyTopHeight, sz.height()); + sz.rwidth() += size.cx + margins.cxLeftWidth + margins.cxRightWidth; + } + if (const QStyleOptionMenuItem *menuitem = qstyleoption_cast(option)) { - int minimumHeight = qMax(22, sz.height()); if (menuitem->menuItemType != QStyleOptionMenuItem::Separator) sz.setHeight(minimumHeight); } @@ -2318,9 +2363,9 @@ int QWindowsVistaStyle::pixelMetric(PixelMetric metric, const QStyleOption *opti switch (metric) { case PM_DockWidgetTitleBarButtonMargin: - return 5; + return int(QStyleHelper::dpiScaled(5.)); case PM_ScrollBarSliderMin: - return 18; + return int(QStyleHelper::dpiScaled(18.)); case PM_MenuHMargin: case PM_MenuVMargin: return 0; diff --git a/src/gui/styles/qwindowsxpstyle.cpp b/src/gui/styles/qwindowsxpstyle.cpp index b0eae1f..322bfac 100644 --- a/src/gui/styles/qwindowsxpstyle.cpp +++ b/src/gui/styles/qwindowsxpstyle.cpp @@ -3235,7 +3235,7 @@ int QWindowsXPStyle::pixelMetric(PixelMetric pm, const QStyleOption *option, con break; case PM_SplitterWidth: - res = qMax(5, QApplication::globalStrut().width()); + res = qMax(int(QStyleHelper::dpiScaled(5.)), QApplication::globalStrut().width()); break; case PM_IndicatorWidth: @@ -3245,7 +3245,7 @@ int QWindowsXPStyle::pixelMetric(PixelMetric pm, const QStyleOption *option, con if (theme.isValid()) { SIZE size; pGetThemePartSize(theme.handle(), 0, theme.partId, theme.stateId, 0, TS_TRUE, &size); - res = (pm == PM_IndicatorWidth ? size.cx+2 : res = size.cy+2); + res = (pm == PM_IndicatorWidth ? size.cx : res = size.cy); } } break; @@ -3257,7 +3257,7 @@ int QWindowsXPStyle::pixelMetric(PixelMetric pm, const QStyleOption *option, con if (theme.isValid()) { SIZE size; pGetThemePartSize(theme.handle(), 0, theme.partId, theme.stateId, 0, TS_TRUE, &size); - res = (pm == PM_ExclusiveIndicatorWidth ? size.cx+2 : res = size.cy+2); + res = (pm == PM_ExclusiveIndicatorWidth ? size.cx : res = size.cy); } } break; @@ -3329,7 +3329,7 @@ int QWindowsXPStyle::pixelMetric(PixelMetric pm, const QStyleOption *option, con #ifndef QT_NO_TOOLBAR case PM_ToolBarHandleExtent: - res = 8; + res = int(QStyleHelper::dpiScaled(8.)); break; #endif // QT_NO_TOOLBAR @@ -3344,10 +3344,10 @@ int QWindowsXPStyle::pixelMetric(PixelMetric pm, const QStyleOption *option, con } break; case PM_DockWidgetSeparatorExtent: - res = 4; + res = int(QStyleHelper::dpiScaled(4.)); break; case PM_DockWidgetTitleMargin: - res = 4; + res = int(QStyleHelper::dpiScaled(4.)); break; case PM_ButtonShiftHorizontal: -- cgit v0.12 From e32bc79d9ab52e5b70e3cd27bddb2bec9c81f5a5 Mon Sep 17 00:00:00 2001 From: Justin McPherson Date: Fri, 26 Jun 2009 11:59:52 +1000 Subject: Always iodbc on OSX platform. Reviewed-by: Bill King --- configure | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/configure b/configure index e0b8b3e..b087d42 100755 --- a/configure +++ b/configure @@ -4435,7 +4435,7 @@ for _SQLDR in $CFG_SQL_AVAILABLE; do ;; odbc) if [ "$CFG_SQL_odbc" != "no" ]; then - if "$unixtests/compile.test" "$XQMAKESPEC" "$QMAKE_CONFIG" $OPT_VERBOSE "$relpath" "$outpath" config.tests/unix/odbc "ODBC" $L_FLAGS $I_FLAGS $l_FLAGS $MAC_CONFIG_TEST_COMMANDLINE; then + if [ "$PLATFORM_MAC" != "yes"] && "$unixtests/compile.test" "$XQMAKESPEC" "$QMAKE_CONFIG" $OPT_VERBOSE "$relpath" "$outpath" config.tests/unix/odbc "ODBC" $L_FLAGS $I_FLAGS $l_FLAGS $MAC_CONFIG_TEST_COMMANDLINE; then if [ "$CFG_SQL_odbc" = "auto" ]; then CFG_SQL_odbc=plugin fi -- cgit v0.12 From 7278c142089d46946d1ad2558eae949220dfe0c4 Mon Sep 17 00:00:00 2001 From: Gareth Pethig Date: Fri, 26 Jun 2009 16:26:56 +1000 Subject: Eliminate warning during configure .../configure: line 4462: [: missing `]' Reviewed-by: Jason McDonald --- configure | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/configure b/configure index 8fee7c9..f9b3030 100755 --- a/configure +++ b/configure @@ -4459,7 +4459,7 @@ for _SQLDR in $CFG_SQL_AVAILABLE; do ;; odbc) if [ "$CFG_SQL_odbc" != "no" ]; then - if [ "$PLATFORM_MAC" != "yes"] && "$unixtests/compile.test" "$XQMAKESPEC" "$QMAKE_CONFIG" $OPT_VERBOSE "$relpath" "$outpath" config.tests/unix/odbc "ODBC" $L_FLAGS $I_FLAGS $l_FLAGS $MAC_CONFIG_TEST_COMMANDLINE; then + if [ "$PLATFORM_MAC" != "yes" ] && "$unixtests/compile.test" "$XQMAKESPEC" "$QMAKE_CONFIG" $OPT_VERBOSE "$relpath" "$outpath" config.tests/unix/odbc "ODBC" $L_FLAGS $I_FLAGS $l_FLAGS $MAC_CONFIG_TEST_COMMANDLINE; then if [ "$CFG_SQL_odbc" = "auto" ]; then CFG_SQL_odbc=plugin fi -- cgit v0.12