From fbbdf8698fb0444d5170b7d0a14e870ea789398f Mon Sep 17 00:00:00 2001 From: Morten Engvoldsen Date: Thu, 19 Nov 2009 14:32:27 +0100 Subject: Doc: Adding documentation on Embedded Hardware acceleration Added "best practice" page on HW acc for mebedded. Modified HW acc docs. Adding Hello GL ES for Wince to the list of examples. QTBUG-5791 David Boddie --- doc/src/getting-started/examples.qdoc | 1 + doc/src/howtos/HWacceleration.qdoc | 100 ++++++++ doc/src/platforms/emb-HwAcc-LinuxEmbedded.qdoc | 62 +++-- doc/src/platforms/emb-HwAcc-WinCE.qdoc | 1 - doc/src/platforms/emb-hardwareacceleration.qdocinc | 269 +++++++++++---------- 5 files changed, 289 insertions(+), 144 deletions(-) create mode 100644 doc/src/howtos/HWacceleration.qdoc diff --git a/doc/src/getting-started/examples.qdoc b/doc/src/getting-started/examples.qdoc index b5dc03d..e951804 100644 --- a/doc/src/getting-started/examples.qdoc +++ b/doc/src/getting-started/examples.qdoc @@ -794,6 +794,7 @@ \o \l{opengl/framebufferobject2}{Framebuffer Object 2} \o \l{opengl/grabber}{Grabber} \o \l{opengl/hellogl}{Hello GL}\raisedaster + \o \l{opengl/hellogl_es}{Hello GL - ported to Windows CE}\raisedaster \o \l{opengl/overpainting}{Overpainting}\raisedaster \o \l{opengl/pbuffers}{Pixel Buffers} \o \l{opengl/pbuffers2}{Pixel Buffers 2} diff --git a/doc/src/howtos/HWacceleration.qdoc b/doc/src/howtos/HWacceleration.qdoc new file mode 100644 index 0000000..80db740 --- /dev/null +++ b/doc/src/howtos/HWacceleration.qdoc @@ -0,0 +1,100 @@ +/**************************************************************************** +** +** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the documentation of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** No Commercial Usage +** This file contains pre-release code and may not be distributed. +** You may use this file in accordance with the terms and conditions +** contained in the Technology Preview License Agreement accompanying +** this package. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** If you have questions regarding the use of this file, please contact +** Nokia at qt-info@nokia.com. +** +** +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +/*! + \page HWAcc_rendering.html + \title Using hardware acceleration on embedded platforms. + + \ingroup best-practices + + \section1 Abstract + This document describes how to use hardware acceleration for fast + rendering on embedded platforms supported by Qt. In short, it explains + how the graphics pipeline works. Since there might be differences to + how the APIs are being used on different embedded platforms, a table + links to documentation dedicated to platform specific documentation + for each supported hardware acceleration API. + + \input platforms/emb-hardwareacceleration.qdocinc + + \section1 Supported platforms + Since there might be differences to how the APIs are being used on + the different embedded platforms, this table provides you with links to + pages dedicated to platform specific documentation for each + supported hardware acceleration API. Click the API link for the + platform to go the correct documentation. + + \table + \header + \o Operating System + \o {3,1} Hardware Acceleration Platform + \row + \o \bold {Windows CE} + \o \l {Qt for Windows CE and OpenGL ES}{OpenGL ES} + \o \l {Qt for Windows CE and OpenVG}{OpenVG} + \o + \row + \o \bold {Embedded Linux} + \o \l {Qt for Embedded Linux and OpenGL}{OpenGL ES} + \o \l {Qt for Embedded Linux and OpenVG}{OpenVG} + \o \l {Qt for Embedded Linux and DirectFB}{DirectFB} + \row + \o \bold {Symbian Platform} + \o {3,1} \e {There are currently no support for hardware + acceleration.} + \endtable +\omit + \section1 Examples using hardware acceleration on embedded platforms. + + \table + \header + \o Embedded Platform + \o Example + \row + \o Windows CE + \row + \o Embedded Linux + \endtable +\endomit + + + +*/ diff --git a/doc/src/platforms/emb-HwAcc-LinuxEmbedded.qdoc b/doc/src/platforms/emb-HwAcc-LinuxEmbedded.qdoc index 9c18d87..a9bd167 100644 --- a/doc/src/platforms/emb-HwAcc-LinuxEmbedded.qdoc +++ b/doc/src/platforms/emb-HwAcc-LinuxEmbedded.qdoc @@ -49,23 +49,57 @@ \ingroup qt-embedded-linux - \input platforms/emb-hardwareacceleration.qdocinc + \input platforms/emb-hardwareacceleration.qdocinc -\section1 Supported Hardware Accelerated Graphics APIs + \section1 Windowing on Embedded Linux with Hardware Accelerated Graphics -This list shows which Hardware Accelerated Graphics APIs currently -supported by Qt. + Qt for Embedded Linux includes its own windowing system, QWS. QWS was + designed in 1999, well before graphics acceleration was available for + embedded devices. It does a great job providing a lightweight window + manager including all the expected functionality such as arbitrary + windows that can be moved, resized, minimized, etc. Getting QWS to work + with GPUs is very challenging, particularly with OpenGL and OpenVG + because there is no standard way in Linux to share textures across + processes. Some silicon vendors provide private APIs to allow texture + sharing, others do not. These limitations are documented under the + sections describing each type of accelerated hardware APIs. The simplest + most generic support for accelerated graphics is a full screen single + process single window. - \table - \header - \o Supported Hardware Accelerated Graphics APIs - \row - \o \l {Qt for Embedded Linux and OpenGL}{OpenGL ES} - \row - \o \l {Qt for Embedded Linux and OpenVG}{OpenVG} - \row - \o \l {Qt for Embedded Linux and DirectFB}{DirectFB} - \endtable + \section2 General options + \list + \o QWS, not accelerated, allows arbitrary windowing with multiple + processes drawing on the screen. + \o X11 with an accelerated X11 driver provided by the silicon + vendor. Like QWS, this allows arbitrary windows with multiple + processes drawing on the screen. Our experience is that there is + some overhead from X11 which will adversely affect framerates. + Additionally, our experience is that the drivers from silicon + vendors are still maturing. + \o Full screen single process single window. This will always work. + Some additional capabilities are available and are documented in + the acceleration specific API sections. + \endlist + + \section1 Supported Hardware Accelerated Graphics APIs + + This table shows which Hardware Accelerated Graphics APIs currently + supported by Qt. + + \table + \header + \o Supported APIs + \o API Version + \row + \o \l {Qt for Embedded Linux and OpenGL}{OpenGL ES} + \o 1.x and 2.x + \row + \o \l {Qt for Embedded Linux and OpenVG}{OpenVG } + \o 1.1 + \row + \o \l {Qt for Embedded Linux and DirectFB}{DirectFB} + \o 2.0 + \endtable */ diff --git a/doc/src/platforms/emb-HwAcc-WinCE.qdoc b/doc/src/platforms/emb-HwAcc-WinCE.qdoc index 66b6948..b7789f1 100644 --- a/doc/src/platforms/emb-HwAcc-WinCE.qdoc +++ b/doc/src/platforms/emb-HwAcc-WinCE.qdoc @@ -47,7 +47,6 @@ \title Qt for Windows CE Hardware Accelerated Graphics \ingroup qtce - \input platforms/emb-hardwareacceleration.qdocinc \section1 Supported Hardware Accelerated Graphics APIs diff --git a/doc/src/platforms/emb-hardwareacceleration.qdocinc b/doc/src/platforms/emb-hardwareacceleration.qdocinc index 3851628..fb00e09 100644 --- a/doc/src/platforms/emb-hardwareacceleration.qdocinc +++ b/doc/src/platforms/emb-hardwareacceleration.qdocinc @@ -1,129 +1,140 @@ - -\section1 Hardware Acceleration - -When designing applications for embedded devices the choice often stands -between graphics effects and performance. On most devices, you cannot have -both simply because the hardware needed for such operations just is not -there. Still a growing number of devices use hardware dedicated to graphics -operations to improve performance. - -Using graphics acceleration hardware is more power efficient than using the -CPU. The reason for this is that the CPU might require a clock speed that -is up to 20 times higher than the GPU, achieving the same results. E.g. a -typical hardware accelerated mobile graphics unit can rasterize one or two -bilinear texture fetches in one cycle, while a software implementation -takes easily more than 20 cycles. Graphics hardware generally have a much -lower clock speed and memory bandwidth and different level of acceleration -than desktop GPUs. One example is that many GPUs leave out transformation -and lighting from the graphics pipeline and only implements rasterization. - -So the key to write good applications for devices is therefore to limit the -wow factor down to what the target hardware can handle, and to take -advantage of any graphics dedicated hardware. Qt provides several ways to -both render advanced effects on the screen and speed up your application -using hardware accelerated graphics. - -\tableofcontents - -\section2 Qt for Embedded Graphics pipeline - -Qt uses QPainter for all graphics operations. By using the same API -regardless of platform, the code can be reused on different devices. -QPainter use different paint engines implemented in the QPaintEngine API to -do the actual painting. - -The QPaintEngine API provides paint engines for each window system and -painting framework supported by Qt. In regards to Qt for Embedded, this -also includes implementations for OpenGL ES versions 1.1 and 2.0, as well -as OpenVG and DirectFB(Embedded Linux only). - -By using one of these paint engines, you will be able to improve the -graphics performance of your Qt application. However, if the graphics -operations used are not supported, this might as well be a trap, slowing -down your application significantly. This all depends on what kind of -graphics operations that are supported by the target devices hardware -configuration. - -\image platformHWAcc.png - -The paint engine will direct all graphics operations supported by the -devices hardware to the GPU, and from there they are sent to the -framebuffer. Unsupported graphics operations falls back to the -QRasterPaintEngine and are handled by the CPU before sent to the -framebuffer. In the end, the operating system sends the paint updates off -to the screen/display. The fallback operation is quite expensive in regards -to memory consumption, and should be avoided. - -\section2 Hardware configuration requirements - -Before implementing any application using hardware acceleration, it is wise -to get an overview of what kind of hardware accelerated graphics operations -that are available for the target device. - -\note On devices with no hardware acceleration, Qt will use -QRasterPaintEngine, which handles the acceleration using software. On -devices supporting OpenGL ES, OpenVG or DirectFB(not supported by Windows -CE), Qt will use the -respective paint engines to accelerate painting. However, hardware -configurations that only support a limited set of hardware acceleration -features, might slow the application graphics down rather than speeding it -up when using unsupported operations that must fall back to the raster -engine. - -\section3 Different architectures - -Based on the architecture used in a device we can make a recommendation on -which hardware acceleration techniques to use. There are mainly two -different architectures on embedded devices. These are devices with a -Unified Memory Architecture (UMA), and devices with dedicated graphics -memory. Generally, high-end devices will have dedicated graphics memory. -Low-end devices will just use system memory, sometimes reserving a memory -region and sometimes not. - -In addition to this, we can categorize the devices into five types based on -the different graphics operations supported by their hardware. - -\list 1 - \o No support for graphics acceleration. - \o Support for blitter and alpha blending. - \o Support for path based 2D vector graphics. - \o Support for fixed function 3D graphics. - \o Support for programmable 3D graphics. -\endlist - -Based on these characteristics the table below recommends which paint -engines to use with the different types of hardware configurations. - -\section3 Recommended use of hardware acceleration based on hardware - - \table - \header - \o Type - \o UMA - \o Non-UMA - \row - \o \bold {None} - \o Qt Raster Engine - \o Qt Raster Engine - \row - \o \bold {Blitter} - \o DirectFB - \o DirectFB - \row - \o \bold {2D Vector} - \o OpenVG - \o OpenVG - \row - \o \bold {Fixed 3D} - \o OpenGL (ES) 1.x - \o OpenGL (ES) 1.x - \row - \o \bold {Programmable 3D} - \o OpenGL (ES) 2.x - \o OpenGL (ES) 2.x - - \endtable - -\note Since the DirectFB API is quite primitive, the raster paint engine -handles most of the operations. -\note Blitter and Alpha blending is currently not supported on Windows CE. + \section1 Hardware Acceleration + + When designing applications for embedded devices there is often a + compromise between graphics effects and performance. On most + devices, you cannot have both simply because the hardware needed + for such operations just is not there. With a growing number of + devices that use hardware dedicated to graphics operations there is + less need to compromise. + + In addition to enabling dynamic graphics effects, there are two + other benefits to using graphics acceleration. One is that graphics + acceleration hardware is more power efficient than using the CPU. + The reason for this is that the CPU might require a clock speed + that is up to 20 times higher than the GPU, achieving the same + results. E.g. a typical hardware accelerated mobile graphics unit + can rasterize one or two bilinear texture fetches in one cycle, + while a software implementation takes easily more than 20 cycles. + Typical \e {System-on-a-chip} (SoC) graphics hardware generally have + a much lower clock speed and memory bandwidth, and different level + of acceleration than desktop GPUs. One example is that many GPUs + leave out transformation and lighting from the graphics pipeline + and only implements rasterization. + + Another reason to use a GPU is to offload the main CPU, either for + power saving or to perform other operations in parallel. Often + drawing speed with a GPU is not that much faster than a CPU but + the clear benefit of using the GPU is to free up the CPU to perform + other tasks which can be used to create a more responsive use + experience. + + The key to writing good applications for devices is therefore to + limit the wow factor down to what the target hardware can handle, + and to take advantage of any graphics dedicated hardware. Qt + provides several ways to both render advanced effects on the screen + and speed up your application using hardware accelerated graphics. + + \tableofcontents + + \section2 Qt for Embedded Graphics pipeline + + Qt uses QPainter for all graphics operations. By using the same API + regardless of platform, the code can be reused on different devices. + QPainter use different paint engines implemented in the QPaintEngine API to + do the actual painting. + + The QPaintEngine API provides paint engines for each window system and + painting framework supported by Qt. In regards to Qt for Embedded, this + also includes implementations for OpenGL ES versions 1.1 and 2.0, as well + as OpenVG and DirectFB(Embedded Linux only). + + By using one of these paint engines, you will be able to improve the + graphics performance of your Qt application. However, if the graphics + operations used are not supported, this might as well be a trap, slowing + down your application significantly. This all depends on what kind of + graphics operations that are supported by the target devices hardware + configuration. + + \image platformHWAcc.png + + The paint engine will direct all graphics operations supported by the + devices hardware to the GPU, and from there they are sent to the + framebuffer. Unsupported graphics operations falls back to the + QRasterPaintEngine and are handled by the CPU before sent to the + framebuffer. In the end, the operating system sends the paint updates off + to the screen/display. The fallback operation is quite expensive in regards + to memory consumption, and should be avoided. + + \section2 Hardware configuration requirements + + Before implementing any application using hardware acceleration, it is wise + to get an overview of what kind of hardware accelerated graphics operations + that are available for the target device. + + \note On devices with no hardware acceleration, Qt will use + QRasterPaintEngine, which handles the acceleration using software. On + devices supporting OpenGL ES, OpenVG or DirectFB(not supported by Windows + CE), Qt will use the + respective paint engines to accelerate painting. However, hardware + configurations that only support a limited set of hardware acceleration + features, might slow the application graphics down rather than speeding it + up when using unsupported operations that must fall back to the raster + engine. + + \section3 Different architectures + + Based on the architecture used in a device we can make a recommendation on + which hardware acceleration techniques to use. There are mainly two + different architectures on embedded devices. These are devices with a + Unified Memory Architecture (UMA), and devices with dedicated graphics + memory. Generally, high-end devices will have dedicated graphics memory. + Low-end devices will just use system memory, sometimes reserving a memory + region and sometimes not. + + In addition to this, we can categorize the devices into five types based on + the different graphics operations supported by their hardware. + + \list 1 + \o No support for graphics acceleration. + \o Support for blitter and alpha blending. + \o Support for path based 2D vector graphics. + \o Support for fixed function 3D graphics. + \o Support for programmable 3D graphics. + \endlist + + Based on these characteristics the table below recommends which paint + engines to use with the different types of hardware configurations. + + \section3 Recommended use of hardware acceleration based on hardware + + \table + \header + \o Type + \o UMA + \o Non-UMA + \row + \o \bold {None} + \o Qt Raster Engine + \o Qt Raster Engine + \row + \o \bold {Blitter} + \o DirectFB + \o DirectFB + \row + \o \bold {2D Vector} + \o OpenVG + \o OpenVG + \row + \o \bold {Fixed 3D} + \o OpenGL (ES) 1.x + \o OpenGL (ES) 1.x + \row + \o \bold {Programmable 3D} + \o OpenGL (ES) 2.x + \o OpenGL (ES) 2.x + \endtable + + \note Since the DirectFB API is quite primitive, the raster paint engine + handles most of the operations. + + \note Blitter and Alpha blending is currently not supported on Windows CE. -- cgit v0.12 From 51b3c2e652578f5577c07c22e177699d345c1dd7 Mon Sep 17 00:00:00 2001 From: Martin Smith Date: Thu, 19 Nov 2009 15:24:40 +0100 Subject: doc: Added note about including a 3rd party library in the bundle. --- doc/src/deployment/deployment.qdoc | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/doc/src/deployment/deployment.qdoc b/doc/src/deployment/deployment.qdoc index b5b1b9c..f94dde1 100644 --- a/doc/src/deployment/deployment.qdoc +++ b/doc/src/deployment/deployment.qdoc @@ -1490,7 +1490,13 @@ \o Accessibility for Qt3Support is deployed if the application uses the Qt3Support module. \endlist - macdeployqt supports the following options: + \note If you want a 3rd party library to be included in your + application bundle, then you must add an excplicit lib entry for + that library to your application's .pro file. Otherwise, the + \c macdeployqt tool will not copy the 3rd party .dylib into the + bundle. + + \c macdeployqt supports the following options: \list \o -no-plugins: Skip plugin deployment \o -dmg : Create a .dmg disk image -- cgit v0.12 From b752acf1805eebd64e7e833862690e9ebdb714e3 Mon Sep 17 00:00:00 2001 From: Volker Hilsheimer Date: Thu, 19 Nov 2009 17:04:01 +0100 Subject: Document known issue - window resizing slower on Windows 7 due to gesture initialization process creating window handles. --- doc/src/getting-started/known-issues.qdoc | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/doc/src/getting-started/known-issues.qdoc b/doc/src/getting-started/known-issues.qdoc index 5c8888d..0af432d 100644 --- a/doc/src/getting-started/known-issues.qdoc +++ b/doc/src/getting-started/known-issues.qdoc @@ -122,6 +122,11 @@ \o A bug in the Firebird database can cause an application to crash when \c{fbembed.dll} is unloaded. The bug is fixed in version 2.5. + \o On Windows 7, resizing windows is slower than on Vista/Xp. This is because + the gesture initialization process (required for native gesture support) + currently calls winId() on widgets, which causes whole widget hierarchies + to use native window handles. This slows down resizing. + \endlist \section2 Mac OS X -- cgit v0.12 From 34dbd7b720875e4e266beee66f6f41e624ea5aad Mon Sep 17 00:00:00 2001 From: Andre Pedralho Date: Thu, 19 Nov 2009 17:15:38 +0100 Subject: Updated the 'framecapture' WebKit example according to WebKit API changes. Merge-request: 2142 Reviewed-by: Simon Hausmann --- examples/webkit/framecapture/framecapture.cpp | 5 ++--- examples/webkit/framecapture/main.cpp | 2 +- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/examples/webkit/framecapture/framecapture.cpp b/examples/webkit/framecapture/framecapture.cpp index 2c2e11b..4636b8d 100644 --- a/examples/webkit/framecapture/framecapture.cpp +++ b/examples/webkit/framecapture/framecapture.cpp @@ -59,6 +59,7 @@ void FrameCapture::load(const QUrl &url, const QString &outputFileName) m_page.mainFrame()->load(url); m_page.mainFrame()->setScrollBarPolicy(Qt::Vertical, Qt::ScrollBarAlwaysOff); m_page.mainFrame()->setScrollBarPolicy(Qt::Horizontal, Qt::ScrollBarAlwaysOff); + m_page.setViewportSize(QSize(1024, 768)); } void FrameCapture::printProgress(int percent) @@ -88,8 +89,6 @@ void FrameCapture::saveResult(bool ok) int index = m_fileName.lastIndexOf('.'); fileName = fileName.insert(index, "_frame" + QString::number(++frameCounter)); - frame->setClipRenderToViewport(false); - QImage image(frame->contentsSize(), QImage::Format_ARGB32_Premultiplied); image.fill(Qt::transparent); @@ -112,7 +111,7 @@ void FrameCapture::saveFrame(QWebFrame *frame, QImage image, QString fileName) painter.setRenderHint(QPainter::TextAntialiasing, true); painter.setRenderHint(QPainter::SmoothPixmapTransform, true); - frame->render(&painter); + frame->documentElement().render(&painter); painter.end(); diff --git a/examples/webkit/framecapture/main.cpp b/examples/webkit/framecapture/main.cpp index 050947a..65c0026 100644 --- a/examples/webkit/framecapture/main.cpp +++ b/examples/webkit/framecapture/main.cpp @@ -63,7 +63,7 @@ int main(int argc, char * argv[]) return 0; } - QUrl url = QWebView::guessUrlFromString(QString::fromLatin1(argv[1])); + QUrl url = QUrl::fromUserInput(QString::fromLatin1(argv[1])); QString fileName = QString::fromLatin1(argv[2]); QApplication a(argc, argv); -- cgit v0.12 From 45e49fc7a325855c6eafa83b85f5ddfdf793c118 Mon Sep 17 00:00:00 2001 From: Andre Pedralho Date: Thu, 19 Nov 2009 17:15:39 +0100 Subject: Fixing the frame hierarchy traversing in framecapture WebKit example. Merge-request: 2142 Reviewed-by: Simon Hausmann --- examples/webkit/framecapture/framecapture.cpp | 37 ++++++++++++--------------- examples/webkit/framecapture/framecapture.h | 2 +- 2 files changed, 18 insertions(+), 21 deletions(-) diff --git a/examples/webkit/framecapture/framecapture.cpp b/examples/webkit/framecapture/framecapture.cpp index 4636b8d..ef49e93 100644 --- a/examples/webkit/framecapture/framecapture.cpp +++ b/examples/webkit/framecapture/framecapture.cpp @@ -82,39 +82,36 @@ void FrameCapture::saveResult(bool ok) return; } - // save each internal frame in different image files - int frameCounter = 0; - foreach(QWebFrame *frame, m_page.mainFrame()->childFrames()) { - QString fileName(m_fileName); - int index = m_fileName.lastIndexOf('.'); - fileName = fileName.insert(index, "_frame" + QString::number(++frameCounter)); + // save each frame in different image files + saveFrame(m_page.mainFrame()); - QImage image(frame->contentsSize(), QImage::Format_ARGB32_Premultiplied); - image.fill(Qt::transparent); + emit finished(); +} - saveFrame(frame, image, fileName); +void FrameCapture::saveFrame(QWebFrame *frame) +{ + static int frameCounter = 0; + + QString fileName(m_fileName); + if (frameCounter) { + int index = m_fileName.lastIndexOf('.'); + fileName = fileName.insert(index, "_frame" + QString::number(frameCounter)); } - // save the main frame - m_page.setViewportSize(m_page.mainFrame()->contentsSize()); - QImage image(m_page.mainFrame()->contentsSize(), QImage::Format_ARGB32_Premultiplied); + QImage image(frame->contentsSize(), QImage::Format_ARGB32_Premultiplied); image.fill(Qt::transparent); - saveFrame(m_page.mainFrame(), image, m_fileName); - emit finished(); -} - -void FrameCapture::saveFrame(QWebFrame *frame, QImage image, QString fileName) -{ QPainter painter(&image); painter.setRenderHint(QPainter::Antialiasing, true); painter.setRenderHint(QPainter::TextAntialiasing, true); painter.setRenderHint(QPainter::SmoothPixmapTransform, true); - frame->documentElement().render(&painter); - painter.end(); image.save(fileName); + + ++frameCounter; + foreach(QWebFrame *childFrame, frame->childFrames()) + saveFrame(childFrame); } diff --git a/examples/webkit/framecapture/framecapture.h b/examples/webkit/framecapture/framecapture.h index 9de9c43..7a6d5f3 100644 --- a/examples/webkit/framecapture/framecapture.h +++ b/examples/webkit/framecapture/framecapture.h @@ -64,7 +64,7 @@ private: QString m_fileName; int m_percent; - void saveFrame(QWebFrame *frame, QImage image, QString fileName); + void saveFrame(QWebFrame *frame); }; #endif -- cgit v0.12 From 095c92f03e0c01b878eaa0cd1b7844171ce9241f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jo=C3=A3o=20Abecasis?= Date: Thu, 19 Nov 2009 17:15:03 +0100 Subject: Revert check for file size to a warning in QFile::map The check, introduced in c66de8a19b558e14097c402480eeabf0b5ec2351, changes behavior and it is not clear whether we should prevent mmaping beyond EOF. FWIW, python prevents it. Leaving a warning in there for now so as not to break applications that depend on the feature. Task-number: QTBUG-6008 Reviewed-by: Thiago Macieira --- src/corelib/io/qfsfileengine_unix.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/corelib/io/qfsfileengine_unix.cpp b/src/corelib/io/qfsfileengine_unix.cpp index 05e6fab..35737b3 100644 --- a/src/corelib/io/qfsfileengine_unix.cpp +++ b/src/corelib/io/qfsfileengine_unix.cpp @@ -1254,7 +1254,7 @@ uchar *QFSFileEnginePrivate::map(qint64 offset, qint64 size, QFile::MemoryMapFla // undefined behavior. Otherwise, let mmap have its say. if (doStat() && (QT_OFF_T(size) > st.st_size - QT_OFF_T(offset))) - return 0; + qWarning("QFSFileEngine::map: Mapping a file beyond its size is not portable"); int access = 0; if (openMode & QIODevice::ReadOnly) access |= PROT_READ; -- cgit v0.12 From 70f482d84022da55b8cc7580d9993a339165219b Mon Sep 17 00:00:00 2001 From: Oswald Buddenhagen Date: Thu, 19 Nov 2009 22:06:26 +0100 Subject: fix potentially wrong output codec for UTF-16 input files querying the actual codec before the file has been read is pointless --- tools/linguist/lupdate/cpp.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/linguist/lupdate/cpp.cpp b/tools/linguist/lupdate/cpp.cpp index 443abd0..bd7d4ec 100644 --- a/tools/linguist/lupdate/cpp.cpp +++ b/tools/linguist/lupdate/cpp.cpp @@ -2150,9 +2150,9 @@ void loadCPP(Translator &translator, const QStringList &filenames, ConversionDat QTextStream ts(&file); ts.setCodec(codec); ts.setAutoDetectUnicode(true); + parser.setInput(ts, filename); if (ts.codec()->name() == "UTF-16") translator.setCodecName("System"); - parser.setInput(ts, filename); Translator *tor = new Translator; tor->setCodecName(translator.codecName()); parser.setTranslator(tor); -- cgit v0.12 From ae653c8ff92c23c3f9ebbdb753a1e0edea95be7e Mon Sep 17 00:00:00 2001 From: Oswald Buddenhagen Date: Thu, 19 Nov 2009 22:09:28 +0100 Subject: don't overwrite explicitly specified CODECFORTR on UTF-16 input --- tools/linguist/lupdate/cpp.cpp | 2 +- tools/linguist/lupdate/main.cpp | 1 + tools/linguist/shared/translator.h | 2 +- 3 files changed, 3 insertions(+), 2 deletions(-) diff --git a/tools/linguist/lupdate/cpp.cpp b/tools/linguist/lupdate/cpp.cpp index bd7d4ec..7c9b27a 100644 --- a/tools/linguist/lupdate/cpp.cpp +++ b/tools/linguist/lupdate/cpp.cpp @@ -2151,7 +2151,7 @@ void loadCPP(Translator &translator, const QStringList &filenames, ConversionDat ts.setCodec(codec); ts.setAutoDetectUnicode(true); parser.setInput(ts, filename); - if (ts.codec()->name() == "UTF-16") + if (cd.m_outputCodec.isEmpty() && ts.codec()->name() == "UTF-16") translator.setCodecName("System"); Translator *tor = new Translator; tor->setCodecName(translator.codecName()); diff --git a/tools/linguist/lupdate/main.cpp b/tools/linguist/lupdate/main.cpp index bdaec4f..7defee0 100644 --- a/tools/linguist/lupdate/main.cpp +++ b/tools/linguist/lupdate/main.cpp @@ -494,6 +494,7 @@ int main(int argc, char **argv) if (!tmp.isEmpty() && !tmp.first().isEmpty()) { codecForTr = tmp.first().toLatin1(); fetchedTor.setCodecName(codecForTr); + cd.m_outputCodec = codecForTr; } tmp = variables.value("CODECFORSRC"); if (!tmp.isEmpty() && !tmp.first().isEmpty()) { diff --git a/tools/linguist/shared/translator.h b/tools/linguist/shared/translator.h index f29317b..e36f822 100644 --- a/tools/linguist/shared/translator.h +++ b/tools/linguist/shared/translator.h @@ -97,7 +97,7 @@ public: public: QString m_defaultContext; QByteArray m_codecForSource; // CPP, PO & QM specific - QByteArray m_outputCodec; // PO specific + QByteArray m_outputCodec; // CPP & PO specific QString m_unTrPrefix; // QM specific QString m_sourceFileName; QString m_targetFileName; -- cgit v0.12 From 389254874251f91038dff0a0d497a6fd9af09939 Mon Sep 17 00:00:00 2001 From: Simone Fiorentino Date: Fri, 20 Nov 2009 10:37:37 +0100 Subject: Marking the shmid segment to be destroyed. It prevents leaks when the app crashes Merge-request: 2080 Reviewed-by: Denis Dzyubenko --- src/gui/image/qnativeimage.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/gui/image/qnativeimage.cpp b/src/gui/image/qnativeimage.cpp index e4ea2e9..3b43ab6 100644 --- a/src/gui/image/qnativeimage.cpp +++ b/src/gui/image/qnativeimage.cpp @@ -178,6 +178,8 @@ QNativeImage::QNativeImage(int width, int height, QImage::Format format,bool /* if (ok) { xshmimg->data = (char*)shmat(xshminfo.shmid, 0, 0); xshminfo.shmaddr = xshmimg->data; + if (shmctl(xshminfo.shmid, IPC_RMID, 0) == -1) + qWarning() << "Error while marking the shared memory segment to be destroyed"; ok = (xshminfo.shmaddr != (char*)-1); if (ok) image = QImage((uchar *)xshmimg->data, width, height, systemFormat()); -- cgit v0.12 From 8fb9ed08c60b667737a9ae1b209da61fe9c67200 Mon Sep 17 00:00:00 2001 From: Olivier Goffart Date: Fri, 20 Nov 2009 11:16:31 +0100 Subject: Fix for tabwidget usesScrollButton being overriden by stylesheet Setting a stylesheet or reparenting a widget into a widget using style sheet would cause the usesScrollButtons to be reset. Instead we now keep the flag whenever it has been explicitly set by the user rather than querying from the style again. Task-number: QTBUG-3370 Reviewed-by: jbache --- src/gui/widgets/qtabbar.cpp | 4 +++- src/gui/widgets/qtabbar_p.h | 3 ++- tests/auto/qtabbar/tst_qtabbar.cpp | 6 +++++- 3 files changed, 10 insertions(+), 3 deletions(-) diff --git a/src/gui/widgets/qtabbar.cpp b/src/gui/widgets/qtabbar.cpp index 3935c55..8ef6017 100644 --- a/src/gui/widgets/qtabbar.cpp +++ b/src/gui/widgets/qtabbar.cpp @@ -1948,7 +1948,8 @@ void QTabBar::changeEvent(QEvent *event) Q_D(QTabBar); if (event->type() == QEvent::StyleChange) { d->elideMode = Qt::TextElideMode(style()->styleHint(QStyle::SH_TabBar_ElideMode, 0, this)); - d->useScrollButtons = !style()->styleHint(QStyle::SH_TabBar_PreferNoArrows, 0, this); + if (!d->useScrollButtonsSetByUser) + d->useScrollButtons = !style()->styleHint(QStyle::SH_TabBar_PreferNoArrows, 0, this); d->refresh(); } else if (event->type() == QEvent::FontChange) { d->refresh(); @@ -2003,6 +2004,7 @@ bool QTabBar::usesScrollButtons() const void QTabBar::setUsesScrollButtons(bool useButtons) { Q_D(QTabBar); + d->useScrollButtonsSetByUser = true; if (d->useScrollButtons == useButtons) return; d->useScrollButtons = useButtons; diff --git a/src/gui/widgets/qtabbar_p.h b/src/gui/widgets/qtabbar_p.h index 9f3285b..2e8fb6d 100644 --- a/src/gui/widgets/qtabbar_p.h +++ b/src/gui/widgets/qtabbar_p.h @@ -75,7 +75,7 @@ class QTabBarPrivate : public QWidgetPrivate public: QTabBarPrivate() :currentIndex(-1), pressedIndex(-1), shape(QTabBar::RoundedNorth), layoutDirty(false), - drawBase(true), scrollOffset(0), expanding(true), closeButtonOnTabs(false), + drawBase(true), scrollOffset(0), useScrollButtonsSetByUser(false) , expanding(true), closeButtonOnTabs(false), selectionBehaviorOnRemove(QTabBar::SelectRightTab), paintWithOffsets(true), movable(false), dragInProgress(false), documentMode(false), movingTab(0) #ifdef Q_WS_MAC @@ -187,6 +187,7 @@ public: QSize iconSize; Qt::TextElideMode elideMode; bool useScrollButtons; + bool useScrollButtonsSetByUser; bool expanding; bool closeButtonOnTabs; diff --git a/tests/auto/qtabbar/tst_qtabbar.cpp b/tests/auto/qtabbar/tst_qtabbar.cpp index 2db72b9..e83312d 100644 --- a/tests/auto/qtabbar/tst_qtabbar.cpp +++ b/tests/auto/qtabbar/tst_qtabbar.cpp @@ -295,6 +295,10 @@ void tst_QTabBar::setUsesScrollButtons() if (usesArrows != -128) tabBar.setUsesScrollButtons(usesArrows); QTEST(tabBar.usesScrollButtons(), "expectedArrows"); + + // Make sure style sheet does not override user set mode + tabBar.setStyleSheet("QWidget { background-color: #ABA8A6;}"); + QTEST(tabBar.usesScrollButtons(), "expectedArrows"); } void tst_QTabBar::removeLastTab() @@ -532,7 +536,7 @@ void tst_QTabBar::task251184_removeTab() QCOMPARE(bar.count(), 1); QCOMPARE(bar.currentIndex(), 0); - QCOMPARE(bar.tabText(bar.currentIndex()), QString("bar2")); + QCOMPARE(bar.tabText(bar.currentIndex()), QString("bar2")); } -- cgit v0.12 From f8fb064d6b2ad55c66ce1a481e7f829278051fcb Mon Sep 17 00:00:00 2001 From: Thierry Bastian Date: Fri, 20 Nov 2009 11:34:22 +0100 Subject: avoid possible crash when showing a modal dialog from a widget destructor Task-number: QTBUG-5804 Reviewed-by: denis --- src/gui/kernel/qwidget.cpp | 5 +++-- tests/auto/qwidget/tst_qwidget.cpp | 25 +++++++++++++++++++++++++ 2 files changed, 28 insertions(+), 2 deletions(-) diff --git a/src/gui/kernel/qwidget.cpp b/src/gui/kernel/qwidget.cpp index 709f6f3..fbb9115 100644 --- a/src/gui/kernel/qwidget.cpp +++ b/src/gui/kernel/qwidget.cpp @@ -8248,7 +8248,8 @@ bool QWidget::event(QEvent *event) QList childList = d->children; for (int i = 0; i < childList.size(); ++i) { QObject *o = childList.at(i); - QApplication::sendEvent(o, event); + if (o) + QApplication::sendEvent(o, event); } } update(); @@ -8277,7 +8278,7 @@ bool QWidget::event(QEvent *event) QList childList = d->children; for (int i = 0; i < childList.size(); ++i) { QObject *o = childList.at(i); - if (o != QApplication::activeModalWidget()) { + if (o && o != QApplication::activeModalWidget()) { if (qobject_cast(o) && static_cast(o)->isWindow()) { // do not forward the event to child windows, // QApplication does this for us diff --git a/tests/auto/qwidget/tst_qwidget.cpp b/tests/auto/qwidget/tst_qwidget.cpp index 9692c6e..1e3f5f8 100644 --- a/tests/auto/qwidget/tst_qwidget.cpp +++ b/tests/auto/qwidget/tst_qwidget.cpp @@ -384,6 +384,8 @@ private slots: void activateWindow(); + void openModal_taskQTBUG_5804(); + #ifdef Q_OS_SYMBIAN void cbaVisibility(); #endif @@ -9583,6 +9585,29 @@ void tst_QWidget::activateWindow() QTRY_VERIFY(!mainwindow2->isActiveWindow()); } +void tst_QWidget::openModal_taskQTBUG_5804() +{ + class Widget : public QWidget + { + public: + Widget(QWidget *parent) : QWidget(parent) + { + } + ~Widget() + { + QMessageBox msgbox; + QTimer::singleShot(10, &msgbox, SLOT(accept())); + msgbox.exec(); //open a modal dialog + } + }; + + QWidget *win = new QWidget; + new Widget(win); + win->show(); + QTest::qWaitForWindowShown(win); + delete win; +} + #ifdef Q_OS_SYMBIAN void tst_QWidget::cbaVisibility() { -- cgit v0.12 From a222302ca45e33306dacae0aa16a572c13abc483 Mon Sep 17 00:00:00 2001 From: Prasanth Ullattil Date: Fri, 20 Nov 2009 11:51:55 +0100 Subject: Incorrect DropAction returned by QDrag::exec() on Cocoa. The action performed by the latest drag and drop operation is stored in the global DnDParams structure. The QDrag::exec() return value has to be fetcted from this global variable instead of the temporary copy on stack. Commit 0d231c32cc7670d356d486b13648cb5bd471ffef broke this. Task-number: QTBUG-6001 Reviewed-by: Denis --- src/gui/kernel/qcocoaview_mac.mm | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/gui/kernel/qcocoaview_mac.mm b/src/gui/kernel/qcocoaview_mac.mm index a16d1f8..72eedad 100644 --- a/src/gui/kernel/qcocoaview_mac.mm +++ b/src/gui/kernel/qcocoaview_mac.mm @@ -1451,7 +1451,7 @@ Qt::DropAction QDragManager::drag(QDrag *o) [image release]; dragPrivate()->executed_action = Qt::IgnoreAction; object = 0; - Qt::DropAction performedAction(qt_mac_mapNSDragOperation(dndParams.performedAction)); + Qt::DropAction performedAction(qt_mac_mapNSDragOperation(qMacDnDParams()->performedAction)); // do post drag processing, if required. if(performedAction != Qt::IgnoreAction) { // check if the receiver points us to a file location. -- cgit v0.12 From 5cf6f6276a3a9103876937c300c1adce157eebeb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Trond=20Kjern=C3=A5sen?= Date: Fri, 20 Nov 2009 12:24:06 +0100 Subject: Fixed antialiasing in the GL based QGraphicsView demos under X11. All the examples/demos that used a QGraphicsView with a QGLWidget as a viewport, that had multisampling enabled, was broken after 7b61fbf03e170a7da37d5f57ed4053aae719ec7f. This is because the reparented QGLWidget will be forced to use the parent widget's visual, which in this case does not contain any multisample buffers. The QX11Info structure for QGLWidget is put together based on the QGLFormat that is passed into the QGLWidget constructor and will in most cases always be different from the parent widget visual. Task-number: QTBUG-5998 and QTBUG-6003 Reviewed-by: Eskil --- src/gui/kernel/qwidget_x11.cpp | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/gui/kernel/qwidget_x11.cpp b/src/gui/kernel/qwidget_x11.cpp index 7461637..0bc9cbc 100644 --- a/src/gui/kernel/qwidget_x11.cpp +++ b/src/gui/kernel/qwidget_x11.cpp @@ -527,8 +527,13 @@ void QWidgetPrivate::create_sys(WId window, bool initializeWindow, bool destroyO QX11InfoData *xd = &X11->screens[qt_x11_create_desktop_on_screen]; xinfo.setX11Data(xd); } else if (parentXinfo && (parentXinfo->screen() != xinfo.screen() - || parentXinfo->visual() != xinfo.visual())) + || (parentXinfo->visual() != xinfo.visual() + && !q->inherits("QGLWidget")))) { + // QGLWidgets have to be excluded here as they have a + // specially crafted QX11Info structure which can't be swapped + // out with the parent widgets QX11Info. The parent visual, + // for instance, might not even be GL capable. xinfo = *parentXinfo; } -- cgit v0.12 From 8b45a7a160daa0d6b38ae1f6cbfd8162c580574b Mon Sep 17 00:00:00 2001 From: Martin Smith Date: Fri, 20 Nov 2009 13:27:01 +0100 Subject: doc: Fixed the last qdoc errors (this time). --- doc/src/getting-started/known-issues.qdoc | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/doc/src/getting-started/known-issues.qdoc b/doc/src/getting-started/known-issues.qdoc index 0af432d..b76b881 100644 --- a/doc/src/getting-started/known-issues.qdoc +++ b/doc/src/getting-started/known-issues.qdoc @@ -61,27 +61,33 @@ \section2 Installing the Source Package on Unix systems + \list + \o If you download a Zip source package, you will need to convert Windows-style line endings (CR/LF) to Unix-style line-endings (LF) when you uncompress the package. To do this, give the "-a" option when you run the "unzip' command. - - If you fail to supply the "-a" option when unzipping the package, you + + \o If you fail to supply the "-a" option when unzipping the package, you will see the following error message when you attempt to execute the configure command: "bash: ./configure: /bin/sh^M: bad interpreter: No such file or directory" + \endlist \section2 Installing on Mac OS X 10.6 "Snow Leopard" + \list + \o Performing a new install of the Qt 4.6 beta on Snow Leopard triggers a bug in the installer that causes the install to fail. Updating an existing Qt installation works fine. - There are two workarounds, either disable spotlight for the target + \o There are two workarounds, either disable spotlight for the target drive during the install, or do a custom install where you deselect documentation and examples. Run the installer again as a full install to get the documentation and examples installed. + \endlist \section1 Issues with Third Party Software @@ -107,6 +113,7 @@ \section2 Windows \list + \o When using version 6.14.11.6921 of the NVIDIA drivers for the GeForce 6600 GT under Windows XP, Qt applications which use drag and drop will display reduced size drag and drop icons when run alongside @@ -132,8 +139,10 @@ \section2 Mac OS X \list + \o If a sheet is opened for a given window, clicking the title bar of that window will cause it to flash. This behavior has been reported to Apple (bug number 5827676). + \endlist */ -- cgit v0.12 From 75d68b2b245da91ec9f985893f9b233d9d6a0793 Mon Sep 17 00:00:00 2001 From: Gabriel de Dietrich Date: Fri, 20 Nov 2009 13:40:34 +0100 Subject: Q_ASSERT failure when resizing a span to (1,1) in 1st cell Reviewed-by: Olivier Task-number: QTBUG-6004 --- src/gui/itemviews/qtableview.cpp | 2 +- tests/auto/qtableview/tst_qtableview.cpp | 8 ++++++++ 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/src/gui/itemviews/qtableview.cpp b/src/gui/itemviews/qtableview.cpp index a3877b7..d27e693 100644 --- a/src/gui/itemviews/qtableview.cpp +++ b/src/gui/itemviews/qtableview.cpp @@ -114,7 +114,7 @@ void QSpanCollection::updateSpan(QSpanCollection::Span *span, int old_height) } } else if (old_height > span->height()) { //remove the span from all the subspans lists that intersect the columns not covered anymore - Index::iterator it_y = index.lowerBound(-span->bottom()); + Index::iterator it_y = index.lowerBound(qMin(-span->bottom(), 0)); Q_ASSERT(it_y != index.end()); //it_y must exist since the span is in the list while (-it_y.key() <= span->top() + old_height -1) { if (-it_y.key() > span->bottom()) { diff --git a/tests/auto/qtableview/tst_qtableview.cpp b/tests/auto/qtableview/tst_qtableview.cpp index 46c3fb6..50d6c67 100644 --- a/tests/auto/qtableview/tst_qtableview.cpp +++ b/tests/auto/qtableview/tst_qtableview.cpp @@ -3016,6 +3016,14 @@ void tst_QTableView::spans_data() << QPoint(2, 0) << 1 << 2; + + QTest::newRow("QTBUG-6004: No failing Q_ASSERT, then it passes.") + << 5 << 5 + << (SpanList() << QRect(0, 0, 2, 2) << QRect(0, 0, 1, 1)) + << false + << QPoint(0, 0) + << 1 + << 1; } void tst_QTableView::spans() -- cgit v0.12 From a2c247ed521d88f99a21b4207cdff8ea03e949be Mon Sep 17 00:00:00 2001 From: Thierry Bastian Date: Fri, 20 Nov 2009 13:59:18 +0100 Subject: Do not extend the last toolbar in a line when moving it --- src/gui/widgets/qtoolbararealayout.cpp | 11 ++++++----- src/gui/widgets/qtoolbararealayout_p.h | 1 + 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/src/gui/widgets/qtoolbararealayout.cpp b/src/gui/widgets/qtoolbararealayout.cpp index b7e985c..d09a301 100644 --- a/src/gui/widgets/qtoolbararealayout.cpp +++ b/src/gui/widgets/qtoolbararealayout.cpp @@ -100,7 +100,7 @@ bool QToolBarAreaLayoutItem::skip() const */ QToolBarAreaLayoutLine::QToolBarAreaLayoutLine(Qt::Orientation orientation) - : o(orientation) + : o(orientation), lastVisible(-1) { } @@ -146,7 +146,7 @@ QSize QToolBarAreaLayoutLine::minimumSize() const void QToolBarAreaLayoutLine::fitLayout() { - int last = -1; + lastVisible = -1; int min = pick(o, minimumSize()); int space = pick(o, rect.size()); int extra = qMax(0, space - min); @@ -169,7 +169,7 @@ void QToolBarAreaLayoutLine::fitLayout() extra -= extraSpace; - last = i; + lastVisible = i; } // calculate the positions from the sizes @@ -180,7 +180,7 @@ void QToolBarAreaLayoutLine::fitLayout() continue; item.pos = pos; - if (i == last) // stretch the last item to the end of the line + if (i == lastVisible) // stretch the last item to the end of the line item.size = qMax(0, pick(o, rect.size()) - item.pos); pos += item.size; } @@ -441,7 +441,8 @@ void QToolBarAreaLayoutInfo::moveToolBar(QToolBar *toolbar, int pos) } //update for the current item - current.extendSize(line.o, -extra); + if (k != line.lastVisible) + current.extendSize(line.o, -extra); if (extra >= 0) { previous.extendSize(line.o, extra); diff --git a/src/gui/widgets/qtoolbararealayout_p.h b/src/gui/widgets/qtoolbararealayout_p.h index f0ab80c..afbd455 100644 --- a/src/gui/widgets/qtoolbararealayout_p.h +++ b/src/gui/widgets/qtoolbararealayout_p.h @@ -148,6 +148,7 @@ public: QRect rect; Qt::Orientation o; + int lastVisible; QList toolBarItems; }; -- cgit v0.12 From 4fbf19955d5c018d8f12611d39348b48be3ff006 Mon Sep 17 00:00:00 2001 From: Thierry Bastian Date: Fri, 20 Nov 2009 14:13:03 +0100 Subject: Revert "Do not extend the last toolbar in a line when moving it" make a real fix for the problem is defaulting to sizehint when there is no preferred size set (ie the toolbar hasn't been moved) This reverts commit a2c247ed521d88f99a21b4207cdff8ea03e949be. --- src/gui/widgets/qtoolbararealayout.cpp | 11 +++++------ src/gui/widgets/qtoolbararealayout_p.h | 3 +-- 2 files changed, 6 insertions(+), 8 deletions(-) diff --git a/src/gui/widgets/qtoolbararealayout.cpp b/src/gui/widgets/qtoolbararealayout.cpp index d09a301..b7e985c 100644 --- a/src/gui/widgets/qtoolbararealayout.cpp +++ b/src/gui/widgets/qtoolbararealayout.cpp @@ -100,7 +100,7 @@ bool QToolBarAreaLayoutItem::skip() const */ QToolBarAreaLayoutLine::QToolBarAreaLayoutLine(Qt::Orientation orientation) - : o(orientation), lastVisible(-1) + : o(orientation) { } @@ -146,7 +146,7 @@ QSize QToolBarAreaLayoutLine::minimumSize() const void QToolBarAreaLayoutLine::fitLayout() { - lastVisible = -1; + int last = -1; int min = pick(o, minimumSize()); int space = pick(o, rect.size()); int extra = qMax(0, space - min); @@ -169,7 +169,7 @@ void QToolBarAreaLayoutLine::fitLayout() extra -= extraSpace; - lastVisible = i; + last = i; } // calculate the positions from the sizes @@ -180,7 +180,7 @@ void QToolBarAreaLayoutLine::fitLayout() continue; item.pos = pos; - if (i == lastVisible) // stretch the last item to the end of the line + if (i == last) // stretch the last item to the end of the line item.size = qMax(0, pick(o, rect.size()) - item.pos); pos += item.size; } @@ -441,8 +441,7 @@ void QToolBarAreaLayoutInfo::moveToolBar(QToolBar *toolbar, int pos) } //update for the current item - if (k != line.lastVisible) - current.extendSize(line.o, -extra); + current.extendSize(line.o, -extra); if (extra >= 0) { previous.extendSize(line.o, extra); diff --git a/src/gui/widgets/qtoolbararealayout_p.h b/src/gui/widgets/qtoolbararealayout_p.h index afbd455..134e95a 100644 --- a/src/gui/widgets/qtoolbararealayout_p.h +++ b/src/gui/widgets/qtoolbararealayout_p.h @@ -118,7 +118,7 @@ public: void extendSize(Qt::Orientation o, int extent) { - int newSize = qMax(pick(o, minimumSize()), (preferredSize > 0 ? preferredSize : size) + extent); + int newSize = qMax(pick(o, minimumSize()), (preferredSize > 0 ? preferredSize : pick(o, sizeHint())) + extent); int sizeh = pick(o, sizeHint()); if (newSize == sizeh) { preferredSize = -1; @@ -148,7 +148,6 @@ public: QRect rect; Qt::Orientation o; - int lastVisible; QList toolBarItems; }; -- cgit v0.12 From 0b8639aee92913cdfaa4386aa09dde0f5cb2eaee Mon Sep 17 00:00:00 2001 From: Yoann Lopes Date: Fri, 20 Nov 2009 13:29:57 +0100 Subject: Fixes painting issues when scaling a QGraphicsView. The problem was that the 'exposed rectangle' passed to the Item's paint() function was rounded to Int values, whereas the one passed to drawBackground and drawForeground was not. Autotest included. Task-number: QTBUG-5859 Reviewed-by: bnilsen --- src/gui/graphicsview/qgraphicsitem.cpp | 2 +- tests/auto/qgraphicsview/tst_qgraphicsview.cpp | 39 ++++++++++++++++++++++++++ 2 files changed, 40 insertions(+), 1 deletion(-) diff --git a/src/gui/graphicsview/qgraphicsitem.cpp b/src/gui/graphicsview/qgraphicsitem.cpp index 3f6dff2..710048e 100644 --- a/src/gui/graphicsview/qgraphicsitem.cpp +++ b/src/gui/graphicsview/qgraphicsitem.cpp @@ -1240,7 +1240,7 @@ void QGraphicsItemPrivate::initStyleOption(QStyleOptionGraphicsItem *option, con const QTransform reverseMap = worldTransform.inverted(); const QVector exposedRects(exposedRegion.rects()); for (int i = 0; i < exposedRects.size(); ++i) { - option->exposedRect |= reverseMap.mapRect(exposedRects.at(i)); + option->exposedRect |= reverseMap.mapRect(QRectF(exposedRects.at(i))); if (option->exposedRect.contains(brect)) break; } diff --git a/tests/auto/qgraphicsview/tst_qgraphicsview.cpp b/tests/auto/qgraphicsview/tst_qgraphicsview.cpp index 1ff06c2..797e1fb 100644 --- a/tests/auto/qgraphicsview/tst_qgraphicsview.cpp +++ b/tests/auto/qgraphicsview/tst_qgraphicsview.cpp @@ -235,6 +235,7 @@ private slots: void task259503_scrollingArtifacts(); void QTBUG_4151_clipAndIgnore_data(); void QTBUG_4151_clipAndIgnore(); + void QTBUG_5859_exposedRect(); }; void tst_QGraphicsView::initTestCase() @@ -3867,5 +3868,43 @@ void tst_QGraphicsView::QTBUG_4151_clipAndIgnore() QCOMPARE(view.items(view.rect()).size(), numItems); } +void tst_QGraphicsView::QTBUG_5859_exposedRect() +{ + class CustomScene : public QGraphicsScene + { + public: + CustomScene(const QRectF &rect) : QGraphicsScene(rect) { } + void drawBackground(QPainter *painter, const QRectF &rect) + { lastBackgroundExposedRect = rect; } + QRectF lastBackgroundExposedRect; + }; + + class CustomRectItem : public QGraphicsRectItem + { + public: + CustomRectItem(const QRectF &rect) : QGraphicsRectItem(rect) + { setFlag(QGraphicsItem::ItemUsesExtendedStyleOption); } + void paint(QPainter * painter, const QStyleOptionGraphicsItem *option, QWidget *widget = 0) + { lastExposedRect = option->exposedRect; } + QRectF lastExposedRect; + }; + + CustomScene scene(QRectF(0,0,50,50)); + + CustomRectItem item(scene.sceneRect()); + + scene.addItem(&item); + + QGraphicsView view(&scene); + view.scale(4.15, 4.15); + view.show(); + QTest::qWaitForWindowShown(&view); + + view.viewport()->repaint(10,10,20,20); + QApplication::processEvents(); + + QCOMPARE(item.lastExposedRect, scene.lastBackgroundExposedRect); +} + QTEST_MAIN(tst_QGraphicsView) #include "tst_qgraphicsview.moc" -- cgit v0.12 From b7692016f282251002b3e85dfcb5567bd91a12c0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jo=C3=A3o=20Abecasis?= Date: Fri, 20 Nov 2009 13:50:41 +0100 Subject: Fix regression introduced in 1e6b424b692b20dcfec920f8d3563e520ec1ff05 When processing the result of QIODevice::readLine, forgot to take into account that a '\0' is appended to the array. The terminating character is not accounted for in the number of bytes returned. By pre-allocating a byte for the terminating null character, we make sure we'll actually read 16k bytes on each and every iteration. Task-number: QTBUG-6019 Reviewed-by: Thiago Macieira --- src/corelib/io/qiodevice.cpp | 6 +- tests/auto/qiodevice/tst_qiodevice.cpp | 112 +++++++++++++++++++++++++++++++++ 2 files changed, 117 insertions(+), 1 deletion(-) diff --git a/src/corelib/io/qiodevice.cpp b/src/corelib/io/qiodevice.cpp index b84961f..0e5a2de 100644 --- a/src/corelib/io/qiodevice.cpp +++ b/src/corelib/io/qiodevice.cpp @@ -1157,6 +1157,10 @@ QByteArray QIODevice::readLine(qint64 maxSize) // If resize fails or maxSize == 0, read incrementally if (maxSize == 0) maxSize = INT_MAX; + + // The first iteration needs to leave an extra byte for the terminating null + result.resize(1); + qint64 readResult; do { result.resize(int(qMin(maxSize, result.size() + QIODEVICE_BUFFERSIZE))); @@ -1164,7 +1168,7 @@ QByteArray QIODevice::readLine(qint64 maxSize) if (readResult > 0 || readBytes == 0) readBytes += readResult; } while (readResult == QIODEVICE_BUFFERSIZE - && result[int(readBytes)] != '\n'); + && result[int(readBytes - 1)] != '\n'); } else readBytes = readLine(result.data(), result.size()); diff --git a/tests/auto/qiodevice/tst_qiodevice.cpp b/tests/auto/qiodevice/tst_qiodevice.cpp index 056ad6a..84fd8ad 100644 --- a/tests/auto/qiodevice/tst_qiodevice.cpp +++ b/tests/auto/qiodevice/tst_qiodevice.cpp @@ -77,6 +77,9 @@ private slots: void readLine_data(); void readLine(); + + void readLine2_data(); + void readLine2(); }; // Testing get/set functions @@ -453,5 +456,114 @@ void tst_QIODevice::readLine() QCOMPARE(line.size(), linelen); } +void tst_QIODevice::readLine2_data() +{ + QTest::addColumn("line"); + + QTest::newRow("1024 - 4") << QByteArray(1024 - 4, 'x'); + QTest::newRow("1024 - 3") << QByteArray(1024 - 3, 'x'); + QTest::newRow("1024 - 2") << QByteArray(1024 - 2, 'x'); + QTest::newRow("1024 - 1") << QByteArray(1024 - 1, 'x'); + QTest::newRow("1024" ) << QByteArray(1024 , 'x'); + QTest::newRow("1024 + 1") << QByteArray(1024 + 1, 'x'); + QTest::newRow("1024 + 2") << QByteArray(1024 + 2, 'x'); + + QTest::newRow("4096 - 4") << QByteArray(4096 - 4, 'x'); + QTest::newRow("4096 - 3") << QByteArray(4096 - 3, 'x'); + QTest::newRow("4096 - 2") << QByteArray(4096 - 2, 'x'); + QTest::newRow("4096 - 1") << QByteArray(4096 - 1, 'x'); + QTest::newRow("4096" ) << QByteArray(4096 , 'x'); + QTest::newRow("4096 + 1") << QByteArray(4096 + 1, 'x'); + QTest::newRow("4096 + 2") << QByteArray(4096 + 2, 'x'); + + QTest::newRow("8192 - 4") << QByteArray(8192 - 4, 'x'); + QTest::newRow("8192 - 3") << QByteArray(8192 - 3, 'x'); + QTest::newRow("8192 - 2") << QByteArray(8192 - 2, 'x'); + QTest::newRow("8192 - 1") << QByteArray(8192 - 1, 'x'); + QTest::newRow("8192" ) << QByteArray(8192 , 'x'); + QTest::newRow("8192 + 1") << QByteArray(8192 + 1, 'x'); + QTest::newRow("8192 + 2") << QByteArray(8192 + 2, 'x'); + + QTest::newRow("16384 - 4") << QByteArray(16384 - 4, 'x'); + QTest::newRow("16384 - 3") << QByteArray(16384 - 3, 'x'); + QTest::newRow("16384 - 2") << QByteArray(16384 - 2, 'x'); + QTest::newRow("16384 - 1") << QByteArray(16384 - 1, 'x'); + QTest::newRow("16384" ) << QByteArray(16384 , 'x'); + QTest::newRow("16384 + 1") << QByteArray(16384 + 1, 'x'); + QTest::newRow("16384 + 2") << QByteArray(16384 + 2, 'x'); + + QTest::newRow("20000") << QByteArray(20000, 'x'); + + QTest::newRow("32768 - 4") << QByteArray(32768 - 4, 'x'); + QTest::newRow("32768 - 3") << QByteArray(32768 - 3, 'x'); + QTest::newRow("32768 - 2") << QByteArray(32768 - 2, 'x'); + QTest::newRow("32768 - 1") << QByteArray(32768 - 1, 'x'); + QTest::newRow("32768" ) << QByteArray(32768 , 'x'); + QTest::newRow("32768 + 1") << QByteArray(32768 + 1, 'x'); + QTest::newRow("32768 + 2") << QByteArray(32768 + 2, 'x'); + + QTest::newRow("40000") << QByteArray(40000, 'x'); +} + +void tst_QIODevice::readLine2() +{ + QFETCH(QByteArray, line); + + int length = line.size(); + + QByteArray data("First line.\r\n"); + data.append(line); + data.append("\r\n"); + data.append(line); + data.append("\r\n"); + data.append("\r\n0123456789"); + + { + QBuffer buffer(&data); + buffer.open(QIODevice::ReadOnly); + + buffer.seek(0); + QByteArray temp; + temp.resize(64536); + QCOMPARE(buffer.readLine(temp.data(), temp.size()), qint64(13)); + QCOMPARE(buffer.readLine(temp.data(), temp.size()), qint64(length + 2)); + QCOMPARE(buffer.readLine(temp.data(), temp.size()), qint64(length + 2)); + QCOMPARE(buffer.readLine(temp.data(), temp.size()), qint64(2)); + QCOMPARE(buffer.readLine(temp.data(), temp.size()), qint64(10)); + QCOMPARE(buffer.readLine(temp.data(), temp.size()), qint64(-1)); + + buffer.seek(0); + QCOMPARE(buffer.readLine().size(), 13); + QCOMPARE(buffer.readLine().size(), length + 2); + QCOMPARE(buffer.readLine().size(), length + 2); + QCOMPARE(buffer.readLine().size(), 2); + QCOMPARE(buffer.readLine().size(), 10); + QVERIFY(buffer.readLine().isNull()); + } + + { + QBuffer buffer(&data); + buffer.open(QIODevice::ReadOnly | QIODevice::Text); + + buffer.seek(0); + QByteArray temp; + temp.resize(64536); + QCOMPARE(buffer.readLine(temp.data(), temp.size()), qint64(12)); + QCOMPARE(buffer.readLine(temp.data(), temp.size()), qint64(length + 1)); + QCOMPARE(buffer.readLine(temp.data(), temp.size()), qint64(length + 1)); + QCOMPARE(buffer.readLine(temp.data(), temp.size()), qint64(1)); + QCOMPARE(buffer.readLine(temp.data(), temp.size()), qint64(10)); + QCOMPARE(buffer.readLine(temp.data(), temp.size()), qint64(-1)); + + buffer.seek(0); + QCOMPARE(buffer.readLine().size(), 12); + QCOMPARE(buffer.readLine().size(), length + 1); + QCOMPARE(buffer.readLine().size(), length + 1); + QCOMPARE(buffer.readLine().size(), 1); + QCOMPARE(buffer.readLine().size(), 10); + QVERIFY(buffer.readLine().isNull()); + } +} + QTEST_MAIN(tst_QIODevice) #include "tst_qiodevice.moc" -- cgit v0.12 From 68595bbc28ba0d1cd78557c61011dc004a4a507c Mon Sep 17 00:00:00 2001 From: Oswald Buddenhagen Date: Fri, 20 Nov 2009 16:35:41 +0100 Subject: fix encodings, take N Task-number: QTBUG-4499 Task-number: QTBUG-5276 --- .../lupdate/testdata/good/codecforsrc/main.cpp | 13 +++++++++++-- .../testdata/good/codecforsrc/project.ts.result | 22 ++++++++++++++++++++-- .../testdata/good/codecfortr/project.ts.result | 2 +- .../lupdate/testdata/good/codecfortr1/main.cpp | 6 ++++-- .../testdata/good/codecfortr1/project.ts.result | 16 +++++++++++++--- .../lupdate/testdata/good/codecfortr2/main.cpp | 5 +++-- .../testdata/good/codecfortr2/project.ts.result | 11 ++++++++--- tools/linguist/lupdate/cpp.cpp | 22 ++++++++++------------ tools/linguist/shared/translator.cpp | 11 ++++++++--- tools/linguist/shared/translator.h | 5 +++-- 10 files changed, 81 insertions(+), 32 deletions(-) diff --git a/tests/auto/linguist/lupdate/testdata/good/codecforsrc/main.cpp b/tests/auto/linguist/lupdate/testdata/good/codecforsrc/main.cpp index 158451a..d99723e 100644 --- a/tests/auto/linguist/lupdate/testdata/good/codecforsrc/main.cpp +++ b/tests/auto/linguist/lupdate/testdata/good/codecforsrc/main.cpp @@ -47,12 +47,21 @@ int main(int argc, char **argv) { QApplication a(argc, argv); + QTextCodec::setCodecForTr(QTextCodec::codecForName("UTF-8")); + QWidget w; QLabel label1(QObject::tr("abc", "ascii"), &w); QLabel label2(QObject::tr("æøå", "utf-8"), &w); + QLabel label2a(QObject::tr("\303\246\303\270\303\245", "utf-8 oct"), &w); + QLabel label3(QObject::trUtf8("Für Élise", "trUtf8"), &w); + QLabel label3a(QObject::trUtf8("F\303\274r \303\211lise", "trUtf8 oct"), &w); -// I would expect the following to work !? -// QLabel label3(QObject::trUtf8("F\374r \310lise", "trUtf8"), &w); + QBoxLayout *ly = new QVBoxLayout(&w); + ly->addWidget(&label1); + ly->addWidget(&label2); + ly->addWidget(&label2a); + ly->addWidget(&label3); + ly->addWidget(&label3a); w.show(); return a.exec(); diff --git a/tests/auto/linguist/lupdate/testdata/good/codecforsrc/project.ts.result b/tests/auto/linguist/lupdate/testdata/good/codecforsrc/project.ts.result index bc0d9bb..711bf02 100644 --- a/tests/auto/linguist/lupdate/testdata/good/codecforsrc/project.ts.result +++ b/tests/auto/linguist/lupdate/testdata/good/codecforsrc/project.ts.result @@ -5,16 +5,34 @@ QObject - + abc ascii - + æøå utf-8 + + + æøå + utf-8 oct + + + + + Für Élise + trUtf8 + + + + + Für Élise + trUtf8 oct + + diff --git a/tests/auto/linguist/lupdate/testdata/good/codecfortr/project.ts.result b/tests/auto/linguist/lupdate/testdata/good/codecfortr/project.ts.result index 91da744..6ee369a 100644 --- a/tests/auto/linguist/lupdate/testdata/good/codecfortr/project.ts.result +++ b/tests/auto/linguist/lupdate/testdata/good/codecfortr/project.ts.result @@ -6,7 +6,7 @@ QObject - Á + Б diff --git a/tests/auto/linguist/lupdate/testdata/good/codecfortr1/main.cpp b/tests/auto/linguist/lupdate/testdata/good/codecfortr1/main.cpp index abb8b89..98b491c 100644 --- a/tests/auto/linguist/lupdate/testdata/good/codecfortr1/main.cpp +++ b/tests/auto/linguist/lupdate/testdata/good/codecfortr1/main.cpp @@ -49,9 +49,11 @@ public: void doFoo() { tr("random ascii only"); - tr("this contains an umlaut ü"); + tr("this contains an umlaut ü literally"); + tr("this contains an umlaut \xfc ü escaped"); trUtf8("random ascii only in utf8"); - trUtf8("umlaut \xfc ü in utf8"); + trUtf8("umlaut ü ü in literal utf8"); + trUtf8("umlaut \303\274 ü in escaped utf8"); } }; diff --git a/tests/auto/linguist/lupdate/testdata/good/codecfortr1/project.ts.result b/tests/auto/linguist/lupdate/testdata/good/codecfortr1/project.ts.result index 26eb245..d548e24 100644 --- a/tests/auto/linguist/lupdate/testdata/good/codecfortr1/project.ts.result +++ b/tests/auto/linguist/lupdate/testdata/good/codecfortr1/project.ts.result @@ -11,17 +11,27 @@ - this contains an umlaut ü &uuml; + this contains an umlaut ü &uuml; literally + this contains an umlaut ü &uuml; escaped + + + + random ascii only in utf8 - - umlaut ü &uuml; in utf8 + + umlaut ü &uuml; in literal utf8 + + + + + umlaut ü &uuml; in escaped utf8 diff --git a/tests/auto/linguist/lupdate/testdata/good/codecfortr2/main.cpp b/tests/auto/linguist/lupdate/testdata/good/codecfortr2/main.cpp index abb8b89..cd93539 100644 --- a/tests/auto/linguist/lupdate/testdata/good/codecfortr2/main.cpp +++ b/tests/auto/linguist/lupdate/testdata/good/codecfortr2/main.cpp @@ -49,9 +49,10 @@ public: void doFoo() { tr("random ascii only"); - tr("this contains an umlaut ü"); + tr("this contains an umlaut ü literally"); + tr("this contains an umlaut \303\274 ü escaped, really in utf-8"); trUtf8("random ascii only in utf8"); - trUtf8("umlaut \xfc ü in utf8"); + trUtf8("umlaut \303\274 ü in escaped utf8"); } }; diff --git a/tests/auto/linguist/lupdate/testdata/good/codecfortr2/project.ts.result b/tests/auto/linguist/lupdate/testdata/good/codecfortr2/project.ts.result index e27c157..6728a25 100644 --- a/tests/auto/linguist/lupdate/testdata/good/codecfortr2/project.ts.result +++ b/tests/auto/linguist/lupdate/testdata/good/codecfortr2/project.ts.result @@ -11,17 +11,22 @@ - this contains an umlaut ü &uuml; + this contains an umlaut ü &uuml; literally - random ascii only in utf8 + this contains an umlaut ü &uuml; escaped, really in utf-8 - umlaut ü &uuml; in utf8 + random ascii only in utf8 + + + + + umlaut ü &uuml; in escaped utf8 diff --git a/tools/linguist/lupdate/cpp.cpp b/tools/linguist/lupdate/cpp.cpp index 7c9b27a..857233e 100644 --- a/tools/linguist/lupdate/cpp.cpp +++ b/tools/linguist/lupdate/cpp.cpp @@ -306,7 +306,6 @@ private: // the string to read from and current position in the string QTextCodec *yySourceCodec; - bool yySourceIsUnicode; QString yyInStr; const ushort *yyInPtr; @@ -353,7 +352,6 @@ void CppParser::setInput(const QString &in) yyInStr = in; yyFileName = QString(); yySourceCodec = 0; - yySourceIsUnicode = true; yyForceUtf8 = true; } @@ -362,7 +360,6 @@ void CppParser::setInput(QTextStream &ts, const QString &fileName) yyInStr = ts.readAll(); yyFileName = fileName; yySourceCodec = ts.codec(); - yySourceIsUnicode = yySourceCodec->name().startsWith("UTF-"); yyForceUtf8 = false; } @@ -1430,24 +1427,24 @@ QString CppParser::transcode(const QString &str, bool utf8) { static const char tab[] = "abfnrtv"; static const char backTab[] = "\a\b\f\n\r\t\v"; - const QString in = (!utf8 || yySourceIsUnicode) - ? str : QString::fromUtf8(yySourceCodec->fromUnicode(str).data()); - QString out; + // This function has to convert back to bytes, as C's \0* sequences work at that level. + const QByteArray in = yyForceUtf8 ? str.toUtf8() : tor->codec()->fromUnicode(str); + QByteArray out; out.reserve(in.length()); for (int i = 0; i < in.length();) { - ushort c = in[i++].unicode(); + uchar c = in[i++]; if (c == '\\') { if (i >= in.length()) break; - c = in[i++].unicode(); + c = in[i++]; if (c == '\n') continue; if (c == 'x') { QByteArray hex; - while (i < in.length() && isxdigit((c = in[i].unicode()))) { + while (i < in.length() && isxdigit((c = in[i]))) { hex += c; i++; } @@ -1456,7 +1453,7 @@ QString CppParser::transcode(const QString &str, bool utf8) QByteArray oct; int n = 0; oct += c; - while (n < 2 && i < in.length() && (c = in[i].unicode()) >= '0' && c < '8') { + while (n < 2 && i < in.length() && (c = in[i]) >= '0' && c < '8') { i++; n++; oct += c; @@ -1464,13 +1461,14 @@ QString CppParser::transcode(const QString &str, bool utf8) out += oct.toUInt(0, 8); } else { const char *p = strchr(tab, c); - out += QChar(QLatin1Char(!p ? c : backTab[p - tab])); + out += !p ? c : backTab[p - tab]; } } else { out += c; } } - return out; + return (utf8 || yyForceUtf8) ? QString::fromUtf8(out.constData(), out.length()) + : tor->codec()->toUnicode(out); } void CppParser::recordMessage( diff --git a/tools/linguist/shared/translator.cpp b/tools/linguist/shared/translator.cpp index 05fc6e5..8a071d3 100644 --- a/tools/linguist/shared/translator.cpp +++ b/tools/linguist/shared/translator.cpp @@ -67,7 +67,7 @@ QString QObject::tr(const char *sourceText, const char *, int n) #endif Translator::Translator() : - m_codecName("ISO-8859-1"), + m_codec(QTextCodec::codecForName("ISO-8859-1")), m_locationsType(AbsoluteLocations) { } @@ -713,12 +713,17 @@ void Translator::setCodecName(const QByteArray &name) if (!codec) { if (!name.isEmpty()) qWarning("No QTextCodec for %s available. Using Latin1\n", name.constData()); - m_codecName = "ISO-8859-1"; + m_codec = QTextCodec::codecForName("ISO-8859-1"); } else { - m_codecName = codec->name(); + m_codec = codec; } } +QByteArray Translator::codecName() const +{ + return m_codec->name(); +} + void Translator::dump() const { for (int i = 0; i != messageCount(); ++i) diff --git a/tools/linguist/shared/translator.h b/tools/linguist/shared/translator.h index e36f822..353cf9d 100644 --- a/tools/linguist/shared/translator.h +++ b/tools/linguist/shared/translator.h @@ -151,7 +151,8 @@ public: void reportDuplicates(const Duplicates &dupes, const QString &fileName, bool verbose); void setCodecName(const QByteArray &name); - QByteArray codecName() const { return m_codecName; } + QByteArray codecName() const; + QTextCodec *codec() const { return m_codec; } QString languageCode() const { return m_language; } QString sourceLanguageCode() const { return m_sourceLanguage; } @@ -211,7 +212,7 @@ private: typedef QList TMM; // int stores the sequence position. TMM m_messages; - QByteArray m_codecName; + QTextCodec *m_codec; LocationsType m_locationsType; // A string beginning with a 2 or 3 letter language code (ISO 639-1 -- cgit v0.12 From 7367a12c4a0d7686b9d35778e5de33a463504d75 Mon Sep 17 00:00:00 2001 From: Oswald Buddenhagen Date: Fri, 20 Nov 2009 21:07:04 +0100 Subject: fix crash on closing "rightmost" file "This cannot happen" ... yeah, right. :} Task-number: QTBUG-5989 --- tools/linguist/linguist/messageeditor.cpp | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/tools/linguist/linguist/messageeditor.cpp b/tools/linguist/linguist/messageeditor.cpp index 616bb26..a7cc636 100644 --- a/tools/linguist/linguist/messageeditor.cpp +++ b/tools/linguist/linguist/messageeditor.cpp @@ -407,10 +407,12 @@ QTextEdit *MessageEditor::activeTranslation() const { if (m_currentNumerus < 0) return 0; - foreach (QTextEdit *te, m_editors[m_currentModel].transTexts[m_currentNumerus]->getEditors()) + const QList &editors = + m_editors[m_currentModel].transTexts[m_currentNumerus]->getEditors(); + foreach (QTextEdit *te, editors) if (te->hasFocus()) return te; - return 0; // This cannot happen + return editors.first(); } QTextEdit *MessageEditor::activeOr1stTranslation() const -- cgit v0.12 From aae4b037317a9ad0d41022d6309f1d4f36443764 Mon Sep 17 00:00:00 2001 From: Oswald Buddenhagen Date: Fri, 20 Nov 2009 21:32:15 +0100 Subject: don't use qWarning for things which are not really warnings ... so the tools are usable with QT_FATAL_WARNINGS. it may be sensible to "degrade" the c++ parser warnings to info messages. possibly later ... Task-number: QTBUG-5683 --- tools/linguist/lconvert/main.cpp | 6 ++++-- tools/linguist/lupdate/main.cpp | 15 +++++++++++---- 2 files changed, 15 insertions(+), 6 deletions(-) diff --git a/tools/linguist/lconvert/main.cpp b/tools/linguist/lconvert/main.cpp index 7807761..5f3de7b 100644 --- a/tools/linguist/lconvert/main.cpp +++ b/tools/linguist/lconvert/main.cpp @@ -46,6 +46,8 @@ #include #include +#include + static int usage(const QStringList &args) { Q_UNUSED(args); @@ -55,7 +57,7 @@ static int usage(const QStringList &args) foreach (Translator::FileFormat format, Translator::registeredFileFormats()) loaders += line.arg(format.extension, -5).arg(format.description); - qWarning("%s", qPrintable(QString(QLatin1String("\nUsage:\n" + std::cerr << qPrintable(QString(QLatin1String("\nUsage:\n" " lconvert [options] [...]\n\n" "lconvert is part of Qt's Linguist tool chain. It can be used as a\n" "stand-alone tool to convert and filter translation data files.\n" @@ -117,7 +119,7 @@ static int usage(const QStringList &args) " 0 on success\n" " 1 on command line parse failures\n" " 2 on read failures\n" - " 3 on write failures\n")).arg(loaders))); + " 3 on write failures\n")).arg(loaders)); return 1; } diff --git a/tools/linguist/lupdate/main.cpp b/tools/linguist/lupdate/main.cpp index 7defee0..9a9af68 100644 --- a/tools/linguist/lupdate/main.cpp +++ b/tools/linguist/lupdate/main.cpp @@ -54,13 +54,20 @@ #include #include +#include + static QString m_defaultExtensions; -static void printOut(const QString & out) +static void printErr(const QString & out) { qWarning("%s", qPrintable(out)); } +static void printOut(const QString & out) +{ + std::cerr << qPrintable(out); +} + static void recursiveFileInfoList(const QDir &dir, const QSet &nameFilters, QDir::Filters filter, QFileInfoList *fileinfolist) @@ -137,7 +144,7 @@ static void updateTsFiles(const Translator &fetchedTor, const QStringList &tsFil cd.m_sortContexts = !(options & NoSort); if (QFile(fileName).exists()) { if (!tor.load(fileName, cd, QLatin1String("auto"))) { - printOut(cd.error()); + printErr(cd.error()); *fail = true; continue; } @@ -197,11 +204,11 @@ static void updateTsFiles(const Translator &fetchedTor, const QStringList &tsFil out.normalizeTranslations(cd); if (!cd.errors().isEmpty()) { - printOut(cd.error()); + printErr(cd.error()); cd.clearErrors(); } if (!out.save(fileName, cd, QLatin1String("auto"))) { - printOut(cd.error()); + printErr(cd.error()); *fail = true; } } -- cgit v0.12 From 50465c3409d699612a59b6c1d16e3502bb3a92fd Mon Sep 17 00:00:00 2001 From: Rhys Weatherley Date: Mon, 23 Nov 2009 07:00:51 +1000 Subject: Support semi-transparent surfaces in the OpenVG graphics system Task-number: QT-2026 Reviewed-by: Jason Barron --- src/openvg/qpaintengine_vg.cpp | 28 ++++++++++++++++++++++++++++ src/openvg/qpaintengine_vg_p.h | 2 ++ src/openvg/qwindowsurface_vg.cpp | 14 +++++++++++--- 3 files changed, 41 insertions(+), 3 deletions(-) diff --git a/src/openvg/qpaintengine_vg.cpp b/src/openvg/qpaintengine_vg.cpp index 75b7fa5..fda4b10 100644 --- a/src/openvg/qpaintengine_vg.cpp +++ b/src/openvg/qpaintengine_vg.cpp @@ -3407,6 +3407,34 @@ void QVGPaintEngine::restoreState(QPaintEngine::DirtyFlags dirty) #endif } +void QVGPaintEngine::fillRegion + (const QRegion& region, const QColor& color, const QSize& surfaceSize) +{ + Q_D(QVGPaintEngine); + if (d->clearColor != color || d->clearOpacity != 1.0f) { + VGfloat values[4]; + values[0] = color.redF(); + values[1] = color.greenF(); + values[2] = color.blueF(); + values[3] = color.alphaF(); + vgSetfv(VG_CLEAR_COLOR, 4, values); + d->clearColor = color; + d->clearOpacity = 1.0f; + } + if (region.rectCount() == 1) { + QRect r = region.boundingRect(); + vgClear(r.x(), surfaceSize.height() - r.y() - r.height(), + r.width(), r.height()); + } else { + const QVector rects = region.rects(); + for (int i = 0; i < rects.size(); ++i) { + QRect r = rects.at(i); + vgClear(r.x(), surfaceSize.height() - r.y() - r.height(), + r.width(), r.height()); + } + } +} + #if !defined(QVG_NO_SINGLE_CONTEXT) && !defined(QT_NO_EGL) QVGCompositionHelper::QVGCompositionHelper() diff --git a/src/openvg/qpaintengine_vg_p.h b/src/openvg/qpaintengine_vg_p.h index 1202b55..86a522a 100644 --- a/src/openvg/qpaintengine_vg_p.h +++ b/src/openvg/qpaintengine_vg_p.h @@ -151,6 +151,8 @@ public: QVGPaintEnginePrivate *vgPrivate() { Q_D(QVGPaintEngine); return d; } + void fillRegion(const QRegion& region, const QColor& color, const QSize& surfaceSize); + protected: QVGPaintEngine(QVGPaintEnginePrivate &data); diff --git a/src/openvg/qwindowsurface_vg.cpp b/src/openvg/qwindowsurface_vg.cpp index f8486a6..a1301e3 100644 --- a/src/openvg/qwindowsurface_vg.cpp +++ b/src/openvg/qwindowsurface_vg.cpp @@ -48,6 +48,7 @@ #if !defined(QT_NO_EGL) #include +#include QT_BEGIN_NAMESPACE @@ -71,7 +72,6 @@ QVGWindowSurface::~QVGWindowSurface() QPaintDevice *QVGWindowSurface::paintDevice() { - d_ptr->beginPaint(window()); return this; } @@ -94,8 +94,16 @@ bool QVGWindowSurface::scroll(const QRegion &area, int dx, int dy) void QVGWindowSurface::beginPaint(const QRegion ®ion) { - // Nothing to do here. - Q_UNUSED(region); + d_ptr->beginPaint(window()); + + // If the window is not opaque, then fill the region we are about + // to paint with the transparent color. + if (!qt_widget_private(window())->isOpaque && + window()->testAttribute(Qt::WA_TranslucentBackground)) { + QVGPaintEngine *engine = static_cast + (d_ptr->paintEngine()); + engine->fillRegion(region, Qt::transparent, d_ptr->surfaceSize()); + } } void QVGWindowSurface::endPaint(const QRegion ®ion) -- cgit v0.12 From 7e7e3c3fe15780aa7d024e136acaf697ab49458c Mon Sep 17 00:00:00 2001 From: Jason McDonald Date: Mon, 23 Nov 2009 14:00:05 +1000 Subject: Fix configure warning for non-symbian builds Configure complains about "Could not retrieve HKEY_LOCAL_MACHINE\Software\Symbian\EPOC SDKs setting". It should only try to do that for Symbian builds. Reviewed-by: Lincoln Ramsay --- src/plugins/sqldrivers/sqlite_symbian/sqlite_symbian.pro | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/plugins/sqldrivers/sqlite_symbian/sqlite_symbian.pro b/src/plugins/sqldrivers/sqlite_symbian/sqlite_symbian.pro index 158633d..9687908 100644 --- a/src/plugins/sqldrivers/sqlite_symbian/sqlite_symbian.pro +++ b/src/plugins/sqldrivers/sqlite_symbian/sqlite_symbian.pro @@ -2,6 +2,8 @@ TEMPLATE = subdirs # We just want to export the sqlite3 binaries for Symbian for platforms that do not have them. -!exists($${EPOCROOT}epoc32/release/armv5/lib/sqlite3.dso) { - BLD_INF_RULES.prj_exports += ":zip SQLite3_v9.2.zip" +symbian { + !exists($${EPOCROOT}epoc32/release/armv5/lib/sqlite3.dso) { + BLD_INF_RULES.prj_exports += ":zip SQLite3_v9.2.zip" + } } -- cgit v0.12 From cda63c368dbb5acd040e2190db8f25de69462d8e Mon Sep 17 00:00:00 2001 From: ninerider Date: Mon, 23 Nov 2009 13:09:56 +0100 Subject: WinCE: only use native menu bars for windows mobile On Windows CE the native menubar must not be used. The corresponding flag was never set for Windows CE. Task-number: QT-2530 Reviewed-by: Maurice --- src/gui/widgets/qmenubar.cpp | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/gui/widgets/qmenubar.cpp b/src/gui/widgets/qmenubar.cpp index e50de02..377b39a 100644 --- a/src/gui/widgets/qmenubar.cpp +++ b/src/gui/widgets/qmenubar.cpp @@ -736,6 +736,9 @@ void QMenuBarPrivate::init() if(wce_menubar) q->hide(); } + else { + QApplication::setAttribute(Qt::AA_DontUseNativeMenuBar, true); + } #endif #ifdef Q_WS_S60 symbianCreateMenuBar(q->parentWidget()); -- cgit v0.12 From 44bea4d915ccfcb43b5392b4b915b9cb40f59faa Mon Sep 17 00:00:00 2001 From: Pierre Rossi Date: Thu, 19 Nov 2009 18:34:43 +0100 Subject: A few tweaks to the frozen column example Reviewed-By: Thierry --- examples/itemviews/frozencolumn/freezetablewidget.cpp | 9 ++++++++- examples/itemviews/frozencolumn/freezetablewidget.h | 1 + examples/itemviews/frozencolumn/grades.txt | 3 ++- 3 files changed, 11 insertions(+), 2 deletions(-) diff --git a/examples/itemviews/frozencolumn/freezetablewidget.cpp b/examples/itemviews/frozencolumn/freezetablewidget.cpp index ee50ae1..72dc2a1 100644 --- a/examples/itemviews/frozencolumn/freezetablewidget.cpp +++ b/examples/itemviews/frozencolumn/freezetablewidget.cpp @@ -84,7 +84,8 @@ void FreezeTableWidget::init() //! [init part2] frozenTableView->setStyleSheet("QTableView { border: none;" - "background-color: #8EDE21;}"); //for demo purposes + "background-color: #8EDE21;" + "selection-background-color: #999}"); //for demo purposes frozenTableView->setSelectionModel(selectionModel()); for(int col=1; colcolumnCount(); col++) frozenTableView->setColumnHidden(col, true); @@ -146,6 +147,12 @@ QModelIndex FreezeTableWidget::moveCursor(CursorAction cursorAction, } //! [navigate] +void FreezeTableWidget::scrollTo (const QModelIndex & index, ScrollHint hint){ + if(index.column()>0) + QTableView::scrollTo(index, hint); +} + + //! [geometry] void FreezeTableWidget::updateFrozenTableGeometry() diff --git a/examples/itemviews/frozencolumn/freezetablewidget.h b/examples/itemviews/frozencolumn/freezetablewidget.h index 403890f..d236d40 100644 --- a/examples/itemviews/frozencolumn/freezetablewidget.h +++ b/examples/itemviews/frozencolumn/freezetablewidget.h @@ -56,6 +56,7 @@ public: protected: virtual void resizeEvent(QResizeEvent *event); virtual QModelIndex moveCursor(CursorAction cursorAction, Qt::KeyboardModifiers modifiers); + void scrollTo (const QModelIndex & index, ScrollHint hint = EnsureVisible); private: QTableView *frozenTableView; diff --git a/examples/itemviews/frozencolumn/grades.txt b/examples/itemviews/frozencolumn/grades.txt index 4b55b473..e1c6fcc 100644 --- a/examples/itemviews/frozencolumn/grades.txt +++ b/examples/itemviews/frozencolumn/grades.txt @@ -32,4 +32,5 @@ 9a+ , , 5.15a , , , XI+ , , , , 12a 9b , , 5.15b , , , , , , , 12b -# Wikipedia contributors. Grade (climbing). Wikipedia, The Free Encyclopedia. May 15, 2009, 20:42 UTC. Available at: http://en.wikipedia.org/w/index.php?title=Grade_(climbing)&oldid=290165724. Accessed May 28, 2009. +# Wikipedia contributors. Grade (climbing). Wikipedia, The Free Encyclopedia. May 15, 2009, 20:42 UTC. +# Available at: http://en.wikipedia.org/w/index.php?title=Grade_(climbing)&oldid=290165724. Accessed May 28, 2009. -- cgit v0.12 From 7ff2d919db8e0addd15c401e5ddda82d061ba5a1 Mon Sep 17 00:00:00 2001 From: Pierre Rossi Date: Thu, 19 Nov 2009 18:27:20 +0100 Subject: updates french phrasebook --- tools/linguist/phrasebooks/french.qph | 36 +++++++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) diff --git a/tools/linguist/phrasebooks/french.qph b/tools/linguist/phrasebooks/french.qph index d710abd..9e1a580 100644 --- a/tools/linguist/phrasebooks/french.qph +++ b/tools/linguist/phrasebooks/french.qph @@ -1402,4 +1402,40 @@ &Redo &Rétablir + + Edit + Éditer + + + PATH: + PATH : + + + Change: + Modification : + + + Edit... + Modifier... + + + &Username: + &Utilisateur : + + + Link + Lien + + + Paste: + Collage : + + + Label + Libellé + + + &Debug + &Déboguer + -- cgit v0.12 From e494b391984a98ea40867cbe6f6bb01726924162 Mon Sep 17 00:00:00 2001 From: Robert Griebl Date: Mon, 23 Nov 2009 20:10:53 +0100 Subject: Fix background rendering for read-only comboboxes on Maemo5 Reviewed-by: jbache --- src/gui/styles/qgtkstyle.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/gui/styles/qgtkstyle.cpp b/src/gui/styles/qgtkstyle.cpp index 5566cc6..b32c55b 100644 --- a/src/gui/styles/qgtkstyle.cpp +++ b/src/gui/styles/qgtkstyle.cpp @@ -1368,7 +1368,7 @@ void QGtkStyle::drawComplexControl(ComplexControl control, const QStyleOptionCom else { gtkCachedPainter.paintFlatBox(gtkEntry, "entry_bg", contentRect, option->state & State_Enabled ? GTK_STATE_NORMAL : GTK_STATE_INSENSITIVE, - GTK_SHADOW_NONE, style, entryPath + QString::number(focus)); + GTK_SHADOW_NONE, gtkCombo->style, entryPath + QString::number(focus)); } gtkCachedPainter.paintShadow(gtkEntry, comboBox->editable ? "entry" : "frame", frameRect, frameState, -- cgit v0.12