From 410ed81027232e669bf6a28699fa833e56a27ef7 Mon Sep 17 00:00:00 2001 From: Rhys Weatherley Date: Wed, 25 Nov 2009 14:04:28 +1000 Subject: Bind the EGL API type before calling eglMakeCurrent() When mixing GL and VG in the same thread, some devices require that eglBindAPI() be called before eglMakeCurrent() when switching between context types. The EGL spec indicates that this shouldn't be required unless the context parameter is EGL_NO_CONTEXT, but it isn't a big deal to work around slightly non-compliant devices. Reviewed-by: Tom Cooksey --- src/gui/egl/qegl.cpp | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/src/gui/egl/qegl.cpp b/src/gui/egl/qegl.cpp index c0e4890..cf28dc4 100644 --- a/src/gui/egl/qegl.cpp +++ b/src/gui/egl/qegl.cpp @@ -236,6 +236,18 @@ bool QEglContext::makeCurrent(EGLSurface surface) currentSurface = surface; setCurrentContext(apiType, this); + // Force the right API to be bound before making the context current. + // The EGL implementation should be able to figure this out from ctx, + // but some systems require the API to be explicitly set anyway. +#ifdef EGL_OPENGL_ES_API + if (apiType == QEgl::OpenGL) + eglBindAPI(EGL_OPENGL_ES_API); +#endif +#ifdef EGL_OPENVG_API + if (apiType == QEgl::OpenVG) + eglBindAPI(EGL_OPENVG_API); +#endif + bool ok = eglMakeCurrent(dpy, surface, surface, ctx); if (!ok) qWarning() << "QEglContext::makeCurrent():" << errorString(eglGetError()); -- cgit v0.12 From 5b5c098bda20cab7825207640cc69230c1864586 Mon Sep 17 00:00:00 2001 From: Rhys Weatherley Date: Wed, 25 Nov 2009 14:13:51 +1000 Subject: Make QVGCompositionHelper::blitWindow() more generic Previously, the composition helper would use the VG window surface private structure to get the VGImage to blit. This change passes the VGImage and size values in directly so that the composition helper can also be used to blit GL surfaces that have been converted into a VGImage via an EGLImage. Reviewed-by: Tom Cooksey --- src/openvg/qpaintengine_vg.cpp | 7 ++----- src/openvg/qvgcompositionhelper_p.h | 4 ++-- 2 files changed, 4 insertions(+), 7 deletions(-) diff --git a/src/openvg/qpaintengine_vg.cpp b/src/openvg/qpaintengine_vg.cpp index fda4b10..ba97d4f 100644 --- a/src/openvg/qpaintengine_vg.cpp +++ b/src/openvg/qpaintengine_vg.cpp @@ -3459,14 +3459,11 @@ void QVGCompositionHelper::endCompositing() } void QVGCompositionHelper::blitWindow - (QVGEGLWindowSurfacePrivate *surface, const QRect& rect, - const QPoint& topLeft, int opacity) + (VGImage image, const QSize& imageSize, + const QRect& rect, const QPoint& topLeft, int opacity) { - // Get the VGImage that is acting as a back buffer for the window. - VGImage image = surface->surfaceImage(); if (image == VG_INVALID_HANDLE) return; - QSize imageSize = surface->surfaceSize(); // Determine which sub rectangle of the window to draw. QRect sr = rect.translated(-topLeft); diff --git a/src/openvg/qvgcompositionhelper_p.h b/src/openvg/qvgcompositionhelper_p.h index 3afe31e..ed24e73 100644 --- a/src/openvg/qvgcompositionhelper_p.h +++ b/src/openvg/qvgcompositionhelper_p.h @@ -71,8 +71,8 @@ public: void startCompositing(const QSize& screenSize); void endCompositing(); - void blitWindow(QVGEGLWindowSurfacePrivate *surface, const QRect& rect, - const QPoint& topLeft, int opacity); + void blitWindow(VGImage image, const QSize& imageSize, + const QRect& rect, const QPoint& topLeft, int opacity); void fillBackground(const QRegion& region, const QBrush& brush); void drawCursorPixmap(const QPixmap& pixmap, const QPoint& offset); void setScissor(const QRegion& region); -- cgit v0.12 From 339a11182a3e64c9cfbd8082622b5920c90c99c5 Mon Sep 17 00:00:00 2001 From: Shane Kearns Date: Tue, 24 Nov 2009 19:54:02 +0100 Subject: Fix crash in QApplication::beep() on S60 Using an asynchronous API synchronously caused a crash, because the data structure was deleted while an async request is still pending. Depending on the multimedia implementation on the phone, the crash will happen or you just get no sound (or it can even work if the underlying implementation is blocking). Solution is to use the API asynchronously, and delete the handling object in qt_cleanup. Also raised the tone by one octave to be more similar to the system beep. Task-number: QTBUG-6170 Reviewed-by: Janne Anttila Reviewed-by: Miikka Heikkinen --- src/gui/kernel/qapplication_s60.cpp | 56 +++++++++++++++++++++++-------------- 1 file changed, 35 insertions(+), 21 deletions(-) diff --git a/src/gui/kernel/qapplication_s60.cpp b/src/gui/kernel/qapplication_s60.cpp index fb2bc72..89d961c 100644 --- a/src/gui/kernel/qapplication_s60.cpp +++ b/src/gui/kernel/qapplication_s60.cpp @@ -133,36 +133,46 @@ private: TTimeIntervalMicroSeconds iDuration; }; +static QS60Beep* qt_S60Beep = 0; + QS60Beep::~QS60Beep() { + if (iToneUtil) { + switch (iState) { + case EBeepPlaying: + iToneUtil->CancelPlay(); + break; + case EBeepNotPrepared: + iToneUtil->CancelPrepare(); + break; + } + } delete iToneUtil; } QS60Beep* QS60Beep::NewL(TInt aFrequency, TTimeIntervalMicroSeconds aDuration) { - QS60Beep* self=new (ELeave) QS60Beep(); + QS60Beep* self = new (ELeave) QS60Beep(); CleanupStack::PushL(self); self->ConstructL(aFrequency, aDuration); CleanupStack::Pop(); return self; -}; +} void QS60Beep::ConstructL(TInt aFrequency, TTimeIntervalMicroSeconds aDuration) { - iToneUtil=CMdaAudioToneUtility::NewL(*this); - iState=EBeepNotPrepared; - iFrequency=aFrequency; - iDuration=aDuration; - iToneUtil->PrepareToPlayTone(iFrequency,iDuration); + iToneUtil = CMdaAudioToneUtility::NewL(*this); + iState = EBeepNotPrepared; + iFrequency = aFrequency; + iDuration = aDuration; + iToneUtil->PrepareToPlayTone(iFrequency, iDuration); } void QS60Beep::Play() { - if (iState != EBeepNotPrepared) { - if (iState == EBeepPlaying) { - iToneUtil->CancelPlay(); - iState = EBeepPrepared; - } + if (iState == EBeepPlaying) { + iToneUtil->CancelPlay(); + iState = EBeepPrepared; } iToneUtil->Play(); @@ -173,13 +183,14 @@ void QS60Beep::MatoPrepareComplete(TInt aError) { if (aError == KErrNone) { iState = EBeepPrepared; + Play(); } } void QS60Beep::MatoPlayComplete(TInt aError) { Q_UNUSED(aError); - iState=EBeepPrepared; + iState = EBeepPrepared; } @@ -1226,6 +1237,10 @@ void qt_init(QApplicationPrivate * /* priv */, int) *****************************************************************************/ void qt_cleanup() { + if(qt_S60Beep) { + delete qt_S60Beep; + qt_S60Beep = 0; + } QFontCache::cleanup(); // Has to happen now, since QFontEngineS60 has FBS handles // S60 structure and window server session are freed in eventdispatcher destructor as they are needed there @@ -1467,14 +1482,13 @@ void QApplication::setCursorFlashTime(int msecs) void QApplication::beep() { - TInt frequency=440; - TTimeIntervalMicroSeconds duration(500000); - QS60Beep* beep=NULL; - TRAPD(err, beep=QS60Beep::NewL(frequency, duration)); - if (!err) - beep->Play(); - delete beep; - beep=NULL; + if (!qt_S60Beep) { + TInt frequency = 880; + TTimeIntervalMicroSeconds duration(500000); + TRAP_IGNORE(qt_S60Beep=QS60Beep::NewL(frequency, duration)); + } + if (qt_S60Beep) + qt_S60Beep->Play(); } /*! -- cgit v0.12 From 9073a38e2ad3342291e9b2e68cf120a2faba06b0 Mon Sep 17 00:00:00 2001 From: Thierry Bastian Date: Wed, 25 Nov 2009 10:01:23 +0100 Subject: Make sure the cursor of the lineedit doesn't blink when a key is pressed This was a regression against 4.5 Task-number: QTBUG-4944 Reviewed-by: ogoffart --- src/gui/widgets/qlineedit.cpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/gui/widgets/qlineedit.cpp b/src/gui/widgets/qlineedit.cpp index 3800224..785b2bd 100644 --- a/src/gui/widgets/qlineedit.cpp +++ b/src/gui/widgets/qlineedit.cpp @@ -1411,6 +1411,8 @@ bool QLineEdit::event(QEvent * e) QTimer::singleShot(0, this, SLOT(_q_handleWindowActivate())); }else if(e->type() == QEvent::ShortcutOverride){ d->control->processEvent(e); + } else if (e->type() == QEvent::KeyRelease) { + d->control->setCursorBlinkPeriod(QApplication::cursorFlashTime()); } #ifdef QT_KEYPAD_NAVIGATION @@ -1615,6 +1617,8 @@ void QLineEdit::keyPressEvent(QKeyEvent *event) } #endif d->control->processKeyEvent(event); + if (event->isAccepted()) + d->control->setCursorBlinkPeriod(0); } /*! -- cgit v0.12 From acf398f764a7d73f5857d4544df4e06bfe60797a Mon Sep 17 00:00:00 2001 From: Kim Motoyoshi Kalland Date: Wed, 25 Nov 2009 10:04:19 +0100 Subject: Fixed subpixel text antialiasing with the GL2 engine on ATI. Use subpixel antialiasing even if the there is an alpha channel. Reviewed-by: Trond --- src/opengl/gl2paintengineex/qpaintengineex_opengl2.cpp | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/src/opengl/gl2paintengineex/qpaintengineex_opengl2.cpp b/src/opengl/gl2paintengineex/qpaintengineex_opengl2.cpp index 823f919..07432c6 100644 --- a/src/opengl/gl2paintengineex/qpaintengineex_opengl2.cpp +++ b/src/opengl/gl2paintengineex/qpaintengineex_opengl2.cpp @@ -1773,13 +1773,10 @@ bool QGL2PaintEngineEx::begin(QPaintDevice *pdev) d->glyphCacheType = QFontEngineGlyphCache::Raster_A8; #if !defined(QT_OPENGL_ES_2) - if (!d->device->format().alpha() #if defined(Q_WS_WIN) - && qt_cleartype_enabled + if (qt_cleartype_enabled) #endif - ) { d->glyphCacheType = QFontEngineGlyphCache::Raster_RGBMask; - } #endif #if defined(QT_OPENGL_ES_2) -- cgit v0.12 From 503f9eb56d16dcf2a44ad491da8b17b2aea72d7d Mon Sep 17 00:00:00 2001 From: Thierry Bastian Date: Wed, 25 Nov 2009 10:12:51 +0100 Subject: Make the animation timer more consistent We ensure that the startStop timer is always ticking before the animation timer. Task-number: QTBUG-5967 Reviewed-by: Aaron Kennedy --- src/corelib/animation/qabstractanimation.cpp | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/corelib/animation/qabstractanimation.cpp b/src/corelib/animation/qabstractanimation.cpp index ef4989b..299585a 100644 --- a/src/corelib/animation/qabstractanimation.cpp +++ b/src/corelib/animation/qabstractanimation.cpp @@ -229,7 +229,10 @@ void QUnifiedTimer::restartAnimationTimer() void QUnifiedTimer::timerEvent(QTimerEvent *event) { - if (event->timerId() == startStopAnimationTimer.timerId()) { + //in the case of consistent timing we make sure the orders in which events come is always the same + //for that purpose we do as if the startstoptimer would always fire before the animation timer + if ((consistentTiming && startStopAnimationTimer.isActive()) || + event->timerId() == startStopAnimationTimer.timerId()) { startStopAnimationTimer.stop(); //we transfer the waiting animations into the "really running" state @@ -247,7 +250,9 @@ void QUnifiedTimer::timerEvent(QTimerEvent *event) time.start(); } } - } else if (event->timerId() == animationTimer.timerId()) { + } + + if (event->timerId() == animationTimer.timerId()) { // update current time on all top level animations updateAnimationsTime(); restartAnimationTimer(); -- cgit v0.12 From e6010544c06232ff1baed9123c0292a7aff6985e Mon Sep 17 00:00:00 2001 From: Thierry Bastian Date: Wed, 25 Nov 2009 11:20:13 +0100 Subject: skip one test on mac because it uses native menu bars --- tests/auto/qmenubar/tst_qmenubar.cpp | 3 +++ 1 file changed, 3 insertions(+) diff --git a/tests/auto/qmenubar/tst_qmenubar.cpp b/tests/auto/qmenubar/tst_qmenubar.cpp index 320cd8d..7fbb760 100644 --- a/tests/auto/qmenubar/tst_qmenubar.cpp +++ b/tests/auto/qmenubar/tst_qmenubar.cpp @@ -1667,6 +1667,9 @@ void tst_QMenuBar::menubarSizeHint() void tst_QMenuBar::taskQTBUG4965_escapeEaten() { +#ifdef Q_WS_MAC + QSKIP("On Mac, do not test the menubar with escape key", SkipAll); +#endif QMenuBar menubar; QMenu menu("menu1"); QAction *first = menubar.addMenu(&menu); -- cgit v0.12 From b463bd91f5e19ec597990ea736ee51a4baaca338 Mon Sep 17 00:00:00 2001 From: Olivier Goffart Date: Wed, 25 Nov 2009 11:47:46 +0100 Subject: stabilize tests on X11 --- tests/auto/qcombobox/tst_qcombobox.cpp | 2 ++ tests/auto/qmenubar/tst_qmenubar.cpp | 12 ++++++------ tests/auto/qwidget_window/tst_qwidget_window.cpp | 24 ++++++++++++++---------- 3 files changed, 22 insertions(+), 16 deletions(-) diff --git a/tests/auto/qcombobox/tst_qcombobox.cpp b/tests/auto/qcombobox/tst_qcombobox.cpp index af71961..bd5cd70 100644 --- a/tests/auto/qcombobox/tst_qcombobox.cpp +++ b/tests/auto/qcombobox/tst_qcombobox.cpp @@ -2516,10 +2516,12 @@ void tst_QComboBox::task_QTBUG_1071_changingFocusEmitsActivated() layout.addWidget(&edit); w.show(); + QApplication::setActiveWindow(&w); QTest::qWaitForWindowShown(&w); cb.clearEditText(); cb.setFocus(); QApplication::processEvents(); + QTRY_VERIFY(cb.hasFocus()); QTest::keyClick(0, '1'); QCOMPARE(spy.count(), 0); edit.setFocus(); diff --git a/tests/auto/qmenubar/tst_qmenubar.cpp b/tests/auto/qmenubar/tst_qmenubar.cpp index 7fbb760..aa6caae 100644 --- a/tests/auto/qmenubar/tst_qmenubar.cpp +++ b/tests/auto/qmenubar/tst_qmenubar.cpp @@ -168,7 +168,7 @@ private slots: void task256322_highlight(); void menubarSizeHint(); void taskQTBUG4965_escapeEaten(); - + #if defined(QT3_SUPPORT) void indexBasedInsertion_data(); void indexBasedInsertion(); @@ -1360,7 +1360,7 @@ tst_QMenuBar::allowActiveAndDisabled() // disabled menu items are added QMenu fileMenu("&File"); - // Task 241043 : check that second menu is activated + // Task 241043 : check that second menu is activated // if all items are disabled QAction *act = fileMenu.addAction("Disabled"); act->setEnabled(false); @@ -1388,7 +1388,7 @@ tst_QMenuBar::allowActiveAndDisabled() QCOMPARE(mb->activeAction()->text(), fileMenu.title()); else QCOMPARE(mb->activeAction()->text(), fileMenu.title()); - + mb->hide(); #endif //Q_WS_MAC } @@ -1603,7 +1603,7 @@ void tst_QMenuBar::menubarSizeHint() virtual int pixelMetric(PixelMetric metric, const QStyleOption * option = 0, const QWidget * widget = 0 ) const { // I chose strange values (prime numbers to be more sure that the size of the menubar is correct) - switch (metric) + switch (metric) { case QStyle::PM_MenuBarItemSpacing: return 7; @@ -1621,7 +1621,7 @@ void tst_QMenuBar::menubarSizeHint() QMenuBar mb; mb.setNativeMenuBar(false); //we can't check the geometry of native menubars - + mb.setStyle(&style); //this is a list of arbitrary strings so that we check the geometry QStringList list = QStringList() << "trer" << "ezrfgtgvqd" << "sdgzgzerzerzer" << "eerzertz" << "er"; @@ -1675,7 +1675,7 @@ void tst_QMenuBar::taskQTBUG4965_escapeEaten() QAction *first = menubar.addMenu(&menu); menu.addAction("quit", &menubar, SLOT(close()), QKeySequence("ESC")); menubar.show(); - menubar.setActiveWindow(); + QApplication::setActiveWindow(&menubar); QTest::qWaitForWindowShown(&menubar); menubar.setActiveAction(first); QTRY_VERIFY(menu.isVisible()); diff --git a/tests/auto/qwidget_window/tst_qwidget_window.cpp b/tests/auto/qwidget_window/tst_qwidget_window.cpp index 13d1d2d..ec11ab3 100644 --- a/tests/auto/qwidget_window/tst_qwidget_window.cpp +++ b/tests/auto/qwidget_window/tst_qwidget_window.cpp @@ -52,6 +52,9 @@ #include #endif // Q_WS_X11 +#include "../../shared/util.h" + + class tst_QWidget_window : public QWidget { Q_OBJECT @@ -150,7 +153,7 @@ void tst_QWidget_window::tst_show_resize_hide_show() class TestWidget : public QWidget { public: - int m_first, m_next; + int m_first, m_next; bool paintEventReceived; void reset(){ m_first = m_next = 0; paintEventReceived = false; } @@ -163,7 +166,7 @@ public: case QEvent::Show: if (m_first) m_next = event->type(); - else + else m_first = event->type(); break; case QEvent::Paint: @@ -173,7 +176,7 @@ public: break; } return QWidget::event(event); - } + } }; void tst_QWidget_window::tst_windowFilePathAndwindowTitle_data() @@ -289,7 +292,7 @@ void tst_QWidget_window::tst_showWithoutActivating() #else QWidget w; w.show(); - qt_x11_wait_for_window_manager(&w); + QTest::qWaitForWindowShown(&w); QApplication::processEvents(); QApplication::clipboard(); @@ -302,8 +305,11 @@ void tst_QWidget_window::tst_showWithoutActivating() Window window; int revertto; - XGetInputFocus(QX11Info::display(), &window, &revertto); - QCOMPARE(lineEdit->winId(), window); + QTRY_COMPARE(lineEdit->winId(), + (XGetInputFocus(QX11Info::display(), &window, &revertto), window) ); + // Note the use of the , before window because we want the XGetInputFocus to be re-executed + // in each iteration of the inside loop of the QTRY_COMPARE macro + #endif // Q_WS_X11 } @@ -315,11 +321,9 @@ void tst_QWidget_window::tst_paintEventOnSecondShow() w.reset(); w.show(); -#ifdef Q_WS_X11 - QTest::qWait(500); -#endif + QTest::qWaitForWindowShown(&w); QApplication::processEvents(); - QVERIFY(w.paintEventReceived); + QTRY_VERIFY(w.paintEventReceived); } QTEST_MAIN(tst_QWidget_window) -- cgit v0.12 From 800ad1c685060bfb6f469a506e8cd85ff3d81577 Mon Sep 17 00:00:00 2001 From: Alessandro Portale Date: Wed, 25 Nov 2009 12:15:27 +0100 Subject: Removed unused setThemePalette(QStyleOption *option) Not used or missed, anywhere. Reviewed-By: Trustme --- src/gui/styles/qs60style.cpp | 5 ----- src/gui/styles/qs60style_p.h | 2 -- 2 files changed, 7 deletions(-) diff --git a/src/gui/styles/qs60style.cpp b/src/gui/styles/qs60style.cpp index b5c0d4f..03f7a95 100644 --- a/src/gui/styles/qs60style.cpp +++ b/src/gui/styles/qs60style.cpp @@ -459,11 +459,6 @@ void QS60StylePrivate::setThemePalette(QApplication *app) const storeThemePalette(&widgetPalette); } -void QS60StylePrivate::setThemePalette(QStyleOption *option) const -{ - setThemePalette(&option->palette); -} - QPalette* QS60StylePrivate::themePalette() { return m_themePalette; diff --git a/src/gui/styles/qs60style_p.h b/src/gui/styles/qs60style_p.h index ea86bb2..36979a2 100644 --- a/src/gui/styles/qs60style_p.h +++ b/src/gui/styles/qs60style_p.h @@ -418,8 +418,6 @@ public: //set theme palette for application void setThemePalette(QApplication *application) const; - //set theme palette for style option - void setThemePalette(QStyleOption *option) const; //access to theme palette static QPalette* themePalette(); -- cgit v0.12 From eaf355c488070a36eed6b99c794d4b055c788e15 Mon Sep 17 00:00:00 2001 From: ck Date: Wed, 25 Nov 2009 12:32:54 +0100 Subject: Assistant: Move tab widget allocation up. We follow the controversial RABU ("Resource Acquisition Before Usage") pattern here. Patch is actually by con. Reviewed-by: con --- tools/assistant/tools/assistant/centralwidget.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/assistant/tools/assistant/centralwidget.cpp b/tools/assistant/tools/assistant/centralwidget.cpp index 6f6875f..7488662 100644 --- a/tools/assistant/tools/assistant/centralwidget.cpp +++ b/tools/assistant/tools/assistant/centralwidget.cpp @@ -223,6 +223,7 @@ CentralWidget::CentralWidget(QHelpEngine *engine, MainWindow *parent) QString resourcePath = QLatin1String(":/trolltech/assistant/images/"); vboxLayout->setMargin(0); + tabWidget = new QTabWidget(this); #ifndef Q_OS_MAC resourcePath.append(QLatin1String("win")); #else @@ -230,7 +231,6 @@ CentralWidget::CentralWidget(QHelpEngine *engine, MainWindow *parent) tabWidget->setDocumentMode(true); #endif - tabWidget = new QTabWidget(this); connect(tabWidget, SIGNAL(currentChanged(int)), this, SLOT(currentPageChanged(int))); -- cgit v0.12 From 41f58d51cec171ccfa132dad2d863340d3ed2db4 Mon Sep 17 00:00:00 2001 From: Gabriel de Dietrich Date: Wed, 25 Nov 2009 09:44:32 +0100 Subject: Offset in MDI subwindow bar buttons under Mac OS 10.6 Task-number: QTBUG-5830 Reviewed-by: Richard --- src/gui/styles/qmacstyle_mac.mm | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/gui/styles/qmacstyle_mac.mm b/src/gui/styles/qmacstyle_mac.mm index 51c2a96..4075cf7 100644 --- a/src/gui/styles/qmacstyle_mac.mm +++ b/src/gui/styles/qmacstyle_mac.mm @@ -4843,9 +4843,11 @@ void QMacStyle::drawComplexControl(ComplexControl cc, const QStyleOptionComplex uint sc = SC_TitleBarMinButton; ThemeTitleBarWidget tbw = kThemeWidgetCollapseBox; bool active = titlebar->state & State_Active; - int border = 2; - titleBarRect.origin.x += border; - titleBarRect.origin.y -= border; + if (qMacVersion() < QSysInfo::MV_10_6) { + int border = 2; + titleBarRect.origin.x += border; + titleBarRect.origin.y -= border; + } while (sc <= SC_TitleBarCloseButton) { if (sc & titlebar->subControls) { -- cgit v0.12 From a30aa66726c1992a0b21b3663b8080661d899e13 Mon Sep 17 00:00:00 2001 From: Thierry Bastian Date: Wed, 25 Nov 2009 12:33:34 +0100 Subject: Test for the clipboard presence in autotest --- tests/auto/qlineedit/tst_qlineedit.cpp | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/tests/auto/qlineedit/tst_qlineedit.cpp b/tests/auto/qlineedit/tst_qlineedit.cpp index dd5bb29..79d1b3a 100644 --- a/tests/auto/qlineedit/tst_qlineedit.cpp +++ b/tests/auto/qlineedit/tst_qlineedit.cpp @@ -1415,8 +1415,22 @@ void tst_QLineEdit::undo_keypressevents() } #ifndef QT_NO_CLIPBOARD +static bool nativeClipboardWorking() +{ +#ifdef Q_WS_MAC + PasteboardRef pasteboard; + OSStatus status = PasteboardCreate(0, &pasteboard); + if (status == noErr) + CFRelease(pasteboard); + return status == noErr; +#endif + return true; +} + void tst_QLineEdit::QTBUG5786_undoPaste() { + if (!nativeClipboardWorking()) + QSKIP("this machine doesn't support the clipboard", SkipAll); QString initial("initial"); QString string("test"); QString additional("add"); -- cgit v0.12 From 43f24759e063df96d01785061bb0905d0352d36b Mon Sep 17 00:00:00 2001 From: Oswald Buddenhagen Date: Tue, 24 Nov 2009 18:01:51 +0100 Subject: another shot at fixing directory separators in build commands --- translations/translations.pri | 2 +- translations/translations.pro | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/translations/translations.pri b/translations/translations.pri index 5eb7328..7a24a4f 100644 --- a/translations/translations.pri +++ b/translations/translations.pri @@ -9,7 +9,7 @@ defineReplace(prependAll) { } LUPDATE = $$QT_BUILD_TREE/bin/lupdate -locations relative -no-ui-lines -win32:isEmpty(QMAKE_SH):LUPDATE ~= s|/|\\|g +LUPDATE ~= s,/,$$QMAKE_DIR_SEP, ###### Qt Libraries diff --git a/translations/translations.pro b/translations/translations.pro index 60f84e6..ef09dc3 100644 --- a/translations/translations.pro +++ b/translations/translations.pro @@ -1,7 +1,7 @@ TRANSLATIONS = $$files(*.ts) LRELEASE = $$QT_BUILD_TREE/bin/lrelease -win32:isEmpty(QMAKE_SH):LRELEASE ~= s|/|\\|g +LRELEASE ~= s,/,$$QMAKE_DIR_SEP, contains(TEMPLATE_PREFIX, vc):vcproj = 1 -- cgit v0.12 From c361eb5bfc7613b9b584d1b58d5d372000f2a47d Mon Sep 17 00:00:00 2001 From: Oswald Buddenhagen Date: Wed, 25 Nov 2009 12:45:08 +0100 Subject: fix class/struct mismatch in the bootstrap magic qlocale.h includes qobjectdefs.h which forward-declares it as a class. Reviewed-by: aportale --- tools/linguist/shared/translator.h | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/tools/linguist/shared/translator.h b/tools/linguist/shared/translator.h index 353cf9d..fa447a3 100644 --- a/tools/linguist/shared/translator.h +++ b/tools/linguist/shared/translator.h @@ -55,10 +55,12 @@ QT_BEGIN_NAMESPACE #ifdef QT_BOOTSTRAPPED -struct QObject { +class QObject { +public: static QString tr(const char *sourceText, const char * = 0, int n = -1); }; -struct QCoreApplication : public QObject { +class QCoreApplication : public QObject { +public: enum Encoding { CodecForTr }; static QString translate(const char *, const char *sourceText, const char * = 0, Encoding = CodecForTr, int n = -1) -- cgit v0.12 From cee1c16a4738e30db5c011f4ae7e273387b5d998 Mon Sep 17 00:00:00 2001 From: Janne Koskinen Date: Wed, 25 Nov 2009 14:10:45 +0200 Subject: Fixed crash when scrolling with deleted backingstore In Symbian we save memory by deleting widget backingstore from non-visible windows. 12-key FEP is fullscreen and causes the backing store to be deleted but still continues to scroll the view to show current caret position in focused lineedit control. Task-number: QTBUG-5922 Reviewed-by: Jason Barron --- src/gui/painting/qbackingstore.cpp | 2 ++ tests/auto/qwidget/tst_qwidget.cpp | 38 ++++++++++++++++++++++++++++++++++++++ 2 files changed, 40 insertions(+) diff --git a/src/gui/painting/qbackingstore.cpp b/src/gui/painting/qbackingstore.cpp index 8226797..1b8f413 100644 --- a/src/gui/painting/qbackingstore.cpp +++ b/src/gui/painting/qbackingstore.cpp @@ -949,6 +949,8 @@ void QWidgetPrivate::scrollRect(const QRect &rect, int dx, int dy) return; QWidgetBackingStore *wbs = x->backingStore; + if (!wbs) + return; static int accelEnv = -1; if (accelEnv == -1) { diff --git a/tests/auto/qwidget/tst_qwidget.cpp b/tests/auto/qwidget/tst_qwidget.cpp index 1e3f5f8..9960f47 100644 --- a/tests/auto/qwidget/tst_qwidget.cpp +++ b/tests/auto/qwidget/tst_qwidget.cpp @@ -391,6 +391,7 @@ private slots: #endif void focusProxyAndInputMethods(); + void scrollWithoutBackingStore(); private: bool ensureScreenSize(int width, int height); @@ -9703,5 +9704,42 @@ void tst_QWidget::focusProxyAndInputMethods() delete toplevel; } +class scrollWidgetWBS : public QWidget +{ +public: + void deleteBackingStore() + { + if (static_cast(d_ptr.data())->maybeBackingStore()) { + delete static_cast(d_ptr.data())->topData()->backingStore; + static_cast(d_ptr.data())->topData()->backingStore = 0; + } + } + void enableBackingStore() + { + if (!static_cast(d_ptr.data())->maybeBackingStore()) { + static_cast(d_ptr.data())->topData()->backingStore = new QWidgetBackingStore(this); + static_cast(d_ptr.data())->invalidateBuffer(this->rect()); + repaint(); + } + } +}; + +void tst_QWidget::scrollWithoutBackingStore() +{ + scrollWidgetWBS scrollable; + scrollable.resize(100,100); + QLabel child(QString("@"),&scrollable); + child.resize(50,50); + scrollable.show(); + QTest::qWaitForWindowShown(&scrollable); + scrollable.scroll(50,50); + QCOMPARE(child.pos(),QPoint(50,50)); + scrollable.deleteBackingStore(); + scrollable.scroll(-25,-25); + QCOMPARE(child.pos(),QPoint(25,25)); + scrollable.enableBackingStore(); + QCOMPARE(child.pos(),QPoint(25,25)); +} + QTEST_MAIN(tst_QWidget) #include "tst_qwidget.moc" -- cgit v0.12 From ab6fd6f9755ecbd556f1a7824ca0c3fa88148b87 Mon Sep 17 00:00:00 2001 From: Janne Anttila Date: Wed, 25 Nov 2009 13:43:22 +0200 Subject: Fixes for tab/space usage in qwidget.cpp. Reviewed-by: TrustMe --- src/gui/kernel/qwidget.cpp | 30 +++++++++++++++--------------- 1 file changed, 15 insertions(+), 15 deletions(-) diff --git a/src/gui/kernel/qwidget.cpp b/src/gui/kernel/qwidget.cpp index fbb9115..b389054 100644 --- a/src/gui/kernel/qwidget.cpp +++ b/src/gui/kernel/qwidget.cpp @@ -4605,7 +4605,7 @@ void QWidgetPrivate::updateFont(const QFont &font) if (!q->parentWidget() && extra && extra->proxyWidget) { QGraphicsProxyWidget *p = extra->proxyWidget; inheritedFontResolveMask = p->d_func()->inheritedFontResolveMask | p->font().resolve(); - } else + } else #endif //QT_NO_GRAPHICSVIEW if (q->isWindow() && !q->testAttribute(Qt::WA_WindowPropagation)) { inheritedFontResolveMask = 0; @@ -9897,13 +9897,13 @@ void QWidget::scroll(int dx, int dy) Q_D(QWidget); #ifndef QT_NO_GRAPHICSVIEW if (QGraphicsProxyWidget *proxy = QWidgetPrivate::nearestGraphicsProxyWidget(this)) { - // Graphics View maintains its own dirty region as a list of rects; - // until we can connect item updates directly to the view, we must - // separately add a translated dirty region. - if (!d->dirty.isEmpty()) { - foreach (const QRect &rect, (d->dirty.translated(dx, dy)).rects()) - proxy->update(rect); - } + // Graphics View maintains its own dirty region as a list of rects; + // until we can connect item updates directly to the view, we must + // separately add a translated dirty region. + if (!d->dirty.isEmpty()) { + foreach (const QRect &rect, (d->dirty.translated(dx, dy)).rects()) + proxy->update(rect); + } proxy->scroll(dx, dy, proxy->subWidgetRect(this)); return; } @@ -9932,13 +9932,13 @@ void QWidget::scroll(int dx, int dy, const QRect &r) Q_D(QWidget); #ifndef QT_NO_GRAPHICSVIEW if (QGraphicsProxyWidget *proxy = QWidgetPrivate::nearestGraphicsProxyWidget(this)) { - // Graphics View maintains its own dirty region as a list of rects; - // until we can connect item updates directly to the view, we must - // separately add a translated dirty region. - if (!d->dirty.isEmpty()) { - foreach (const QRect &rect, (d->dirty.translated(dx, dy) & r).rects()) - proxy->update(rect); - } + // Graphics View maintains its own dirty region as a list of rects; + // until we can connect item updates directly to the view, we must + // separately add a translated dirty region. + if (!d->dirty.isEmpty()) { + foreach (const QRect &rect, (d->dirty.translated(dx, dy) & r).rects()) + proxy->update(rect); + } proxy->scroll(dx, dy, r.translated(proxy->subWidgetRect(this).topLeft().toPoint())); return; } -- cgit v0.12 From b461da1040c32d6690870290d6716a3b5cb7e9e9 Mon Sep 17 00:00:00 2001 From: Janne Anttila Date: Wed, 25 Nov 2009 14:47:33 +0200 Subject: Fixed context menu not to have "Options" action. When calling QMainWindow::setMenuBar(), menuBarAction ("Options") gets added to widget actions list. This actions will be shown in widget context menu if visible. That's why we set the action invisible. Visibility property does not have impact to softkey contruction, i.e. also invisble softkeys are added. Task-number: QTBUG-6220 Reviewed-by: Jason Barron --- src/gui/widgets/qmainwindow.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/src/gui/widgets/qmainwindow.cpp b/src/gui/widgets/qmainwindow.cpp index 501e62f..557acfb 100644 --- a/src/gui/widgets/qmainwindow.cpp +++ b/src/gui/widgets/qmainwindow.cpp @@ -120,6 +120,7 @@ void QMainWindowPrivate::init() #ifdef QT_SOFTKEYS_ENABLED menuBarAction = QSoftKeyManager::createAction(QSoftKeyManager::MenuSoftKey, q); menuBarAction->setObjectName(QLatin1String("_q_menuSoftKeyAction")); + menuBarAction->setVisible(false); #endif } -- cgit v0.12 From de593891c0e65c74d92958a7f6262ee01c055902 Mon Sep 17 00:00:00 2001 From: Alessandro Portale Date: Wed, 25 Nov 2009 14:11:06 +0100 Subject: Micro optimization Don't request a palette if you do not use it. Reviewed-By: Trustme --- src/gui/styles/qs60style.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/gui/styles/qs60style.cpp b/src/gui/styles/qs60style.cpp index 03f7a95..974c3ff 100644 --- a/src/gui/styles/qs60style.cpp +++ b/src/gui/styles/qs60style.cpp @@ -633,11 +633,11 @@ void QS60StylePrivate::setThemePalette(QWidget *widget) const { if(!widget) return; - QPalette widgetPalette = QApplication::palette(widget); //header view and its viewport need to be set 100% transparent button color, since drawing code will //draw transparent theme graphics to table column and row headers. if (qobject_cast(widget)){ + QPalette widgetPalette = QApplication::palette(widget); widgetPalette.setColor(QPalette::Active, QPalette::ButtonText, s60Color(QS60StyleEnums::CL_QsnTextColors, 23, 0)); QHeaderView* header = qobject_cast(widget); -- cgit v0.12 From 2a3a270e5d2a26b9ef7405abfa1892beaece9b04 Mon Sep 17 00:00:00 2001 From: Janne Anttila Date: Wed, 25 Nov 2009 15:48:22 +0200 Subject: Fix for "saxbookmarks - file dialog starts in wrong directory (winscw)" QCoreApplication::applicationFilePath() in emulator returns path to Z drive. Use QDesktopServices instead which always returns the writable drive. Task-number: QTBUG-6117 Reviewed-by: Miikka Heikkinen --- examples/xml/saxbookmarks/mainwindow.cpp | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/examples/xml/saxbookmarks/mainwindow.cpp b/examples/xml/saxbookmarks/mainwindow.cpp index 49cb468..ff3cf11 100644 --- a/examples/xml/saxbookmarks/mainwindow.cpp +++ b/examples/xml/saxbookmarks/mainwindow.cpp @@ -67,8 +67,11 @@ MainWindow::MainWindow() void MainWindow::open() { #if defined(Q_OS_SYMBIAN) - // Always look for bookmarks on the same drive where the application is installed to. - QString bookmarksFolder = QCoreApplication::applicationFilePath().left(1); + // Look for bookmarks on the same drive where the application is installed to, + // if drive is not read only. QDesktopServices::DataLocation does this check, + // and returns writable drive. + QString bookmarksFolder = + QDesktopServices::storageLocation(QDesktopServices::DataLocation).left(1); bookmarksFolder.append(":/Data/qt/saxbookmarks"); QDir::setCurrent(bookmarksFolder); #endif -- cgit v0.12 From d393ab41a56ef96113fe7928ff30e2ea96825ff1 Mon Sep 17 00:00:00 2001 From: Olivier Goffart Date: Wed, 25 Nov 2009 15:21:02 +0100 Subject: fix languagechange test --- tests/auto/languagechange/tst_languagechange.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/tests/auto/languagechange/tst_languagechange.cpp b/tests/auto/languagechange/tst_languagechange.cpp index 1319f15..449d34b 100644 --- a/tests/auto/languagechange/tst_languagechange.cpp +++ b/tests/auto/languagechange/tst_languagechange.cpp @@ -193,7 +193,7 @@ void tst_languageChange::retranslatability_data() #else << "QFileSystemModel::Type::All other platforms" #endif - << "QFileSystemModel::%1 KB" +// << "QFileSystemModel::%1 KB" << "QDialogButtonBox::Cancel" << "QDialogButtonBox::Open" << "QFileDialog::File &name:"); @@ -232,6 +232,7 @@ void tst_languageChange::retranslatability() QSKIP("The native file dialog is used on Mac OS", SkipSingle); #endif QFileDialog dlg; + dlg.setOption(QFileDialog::DontUseNativeDialog); QString tmpParentDir = QDir::tempPath() + "/languagechangetestdir"; QString tmpDir = tmpParentDir + "/finaldir"; QString fooName = tmpParentDir + "/foo"; -- cgit v0.12 From e4710b39900023796aa785f84ea2ec6a725662d9 Mon Sep 17 00:00:00 2001 From: Olivier Goffart Date: Wed, 25 Nov 2009 15:34:14 +0100 Subject: Fix RCC test --- tests/auto/rcc/data/images.expected | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/auto/rcc/data/images.expected b/tests/auto/rcc/data/images.expected index 24d75b6..71be819 100644 --- a/tests/auto/rcc/data/images.expected +++ b/tests/auto/rcc/data/images.expected @@ -97,10 +97,10 @@ static const unsigned char qt_resource_struct[] = { QT_BEGIN_NAMESPACE -extern bool qRegisterResourceData +extern Q_CORE_EXPORT bool qRegisterResourceData (int, const unsigned char *, const unsigned char *, const unsigned char *); -extern bool qUnregisterResourceData +extern Q_CORE_EXPORT bool qUnregisterResourceData (int, const unsigned char *, const unsigned char *, const unsigned char *); QT_END_NAMESPACE -- cgit v0.12 From c5eea852c73bab203541a08757be2c3cf9a18c1c Mon Sep 17 00:00:00 2001 From: Thierry Bastian Date: Wed, 25 Nov 2009 15:35:42 +0100 Subject: Make the spinbox and doublespinbox better accept intermediate input Task-number: QTBUG-5008 Reviewed-by: ogoffart --- src/gui/widgets/qspinbox.cpp | 100 ++++++++--------------- tests/auto/qdoublespinbox/tst_qdoublespinbox.cpp | 38 ++++++++- tests/auto/qspinbox/tst_qspinbox.cpp | 34 ++++++++ 3 files changed, 104 insertions(+), 68 deletions(-) diff --git a/src/gui/widgets/qspinbox.cpp b/src/gui/widgets/qspinbox.cpp index 9eb07ac..50b225c 100644 --- a/src/gui/widgets/qspinbox.cpp +++ b/src/gui/widgets/qspinbox.cpp @@ -65,14 +65,13 @@ class QSpinBoxPrivate : public QAbstractSpinBoxPrivate { Q_DECLARE_PUBLIC(QSpinBox) public: - QSpinBoxPrivate(QWidget *parent = 0); + QSpinBoxPrivate(); void emitSignals(EmitPolicy ep, const QVariant &); virtual QVariant valueFromText(const QString &n) const; virtual QString textFromValue(const QVariant &n) const; QVariant validateAndInterpret(QString &input, int &pos, QValidator::State &state) const; - QChar thousand; inline void init() { Q_Q(QSpinBox); @@ -85,7 +84,7 @@ class QDoubleSpinBoxPrivate : public QAbstractSpinBoxPrivate { Q_DECLARE_PUBLIC(QDoubleSpinBox) public: - QDoubleSpinBoxPrivate(QWidget *parent = 0); + QDoubleSpinBoxPrivate(); void emitSignals(EmitPolicy ep, const QVariant &); virtual QVariant valueFromText(const QString &n) const; @@ -95,7 +94,6 @@ public: double round(double input) const; // variables int decimals; - QChar delimiter, thousand; inline void init() { Q_Q(QDoubleSpinBox); @@ -201,7 +199,7 @@ public: */ QSpinBox::QSpinBox(QWidget *parent) - : QAbstractSpinBox(*new QSpinBoxPrivate(parent), parent) + : QAbstractSpinBox(*new QSpinBoxPrivate, parent) { Q_D(QSpinBox); d->init(); @@ -213,7 +211,7 @@ QSpinBox::QSpinBox(QWidget *parent) argument and then use setObjectName() instead. */ QSpinBox::QSpinBox(QWidget *parent, const char *name) - : QAbstractSpinBox(*new QSpinBoxPrivate(parent), parent) + : QAbstractSpinBox(*new QSpinBoxPrivate, parent) { Q_D(QSpinBox); setObjectName(QString::fromAscii(name)); @@ -225,7 +223,7 @@ QSpinBox::QSpinBox(QWidget *parent, const char *name) argument and then use setObjectName() instead. */ QSpinBox::QSpinBox(int minimum, int maximum, int step, QWidget *parent, const char *name) - : QAbstractSpinBox(*new QSpinBoxPrivate(parent), parent) + : QAbstractSpinBox(*new QSpinBoxPrivate, parent) { Q_D(QSpinBox); d->minimum = QVariant(qMin(minimum, maximum)); @@ -464,10 +462,9 @@ void QSpinBox::setRange(int minimum, int maximum) QString QSpinBox::textFromValue(int value) const { - Q_D(const QSpinBox); QString str = locale().toString(value); if (qAbs(value) >= 1000 || value == INT_MIN) { - str.remove(d->thousand); + str.remove(locale().groupSeparator()); } return str; @@ -516,9 +513,7 @@ QValidator::State QSpinBox::validate(QString &text, int &pos) const */ void QSpinBox::fixup(QString &input) const { - Q_D(const QSpinBox); - - input.remove(d->thousand); + input.remove(locale().groupSeparator()); } @@ -600,7 +595,7 @@ void QSpinBox::fixup(QString &input) const \sa setMinimum(), setMaximum(), setSingleStep() */ QDoubleSpinBox::QDoubleSpinBox(QWidget *parent) - : QAbstractSpinBox(*new QDoubleSpinBoxPrivate(parent), parent) + : QAbstractSpinBox(*new QDoubleSpinBoxPrivate, parent) { Q_D(QDoubleSpinBox); d->init(); @@ -875,7 +870,7 @@ QString QDoubleSpinBox::textFromValue(double value) const Q_D(const QDoubleSpinBox); QString str = locale().toString(value, 'f', d->decimals); if (qAbs(value) >= 1000.0) { - str.remove(d->thousand); + str.remove(locale().groupSeparator()); } return str; } @@ -920,9 +915,7 @@ QValidator::State QDoubleSpinBox::validate(QString &text, int &pos) const */ void QDoubleSpinBox::fixup(QString &input) const { - Q_D(const QDoubleSpinBox); - - input.remove(d->thousand); + input.remove(locale().groupSeparator()); } // --- QSpinBoxPrivate --- @@ -932,18 +925,13 @@ void QDoubleSpinBox::fixup(QString &input) const Constructs a QSpinBoxPrivate object */ -QSpinBoxPrivate::QSpinBoxPrivate(QWidget *parent) +QSpinBoxPrivate::QSpinBoxPrivate() { minimum = QVariant((int)0); maximum = QVariant((int)99); value = minimum; singleStep = QVariant((int)1); type = QVariant::Int; - const QString str = (parent ? parent->locale() : QLocale()).toString(4567); - if (str.size() == 5) { - thousand = QChar(str.at(1)); - } - } /*! @@ -1019,20 +1007,17 @@ QVariant QSpinBoxPrivate::validateAndInterpret(QString &input, int &pos, state = QValidator::Invalid; // special-case -0 will be interpreted as 0 and thus not be invalid with a range from 0-100 } else { bool ok = false; - bool removedThousand = false; num = locale.toInt(copy, &ok, 10); - if (!ok && copy.contains(thousand) && (max >= 1000 || min <= -1000)) { - const int s = copy.size(); - copy.remove(thousand); - pos = qMax(0, pos - (s - copy.size())); - removedThousand = true; - num = locale.toInt(copy, &ok, 10); + if (!ok && copy.contains(locale.groupSeparator()) && (max >= 1000 || min <= -1000)) { + QString copy2 = copy; + copy2.remove(locale.groupSeparator()); + num = locale.toInt(copy2, &ok, 10); } QSBDEBUG() << __FILE__ << __LINE__<< "num is set to" << num; if (!ok) { state = QValidator::Invalid; } else if (num >= min && num <= max) { - state = removedThousand ? QValidator::Intermediate : QValidator::Acceptable; + state = QValidator::Acceptable; } else if (max == min) { state = QValidator::Invalid; } else { @@ -1064,7 +1049,7 @@ QVariant QSpinBoxPrivate::validateAndInterpret(QString &input, int &pos, Constructs a QSpinBoxPrivate object */ -QDoubleSpinBoxPrivate::QDoubleSpinBoxPrivate(QWidget *parent) +QDoubleSpinBoxPrivate::QDoubleSpinBoxPrivate() { minimum = QVariant(0.0); maximum = QVariant(99.99); @@ -1072,15 +1057,6 @@ QDoubleSpinBoxPrivate::QDoubleSpinBoxPrivate(QWidget *parent) singleStep = QVariant(1.0); decimals = 2; type = QVariant::Double; - const QString str = (parent ? parent->locale() : QLocale()).toString(4567.1); - if (str.size() == 6) { - delimiter = str.at(4); - thousand = QChar((ushort)0); - } else if (str.size() == 7) { - thousand = str.at(1); - delimiter = str.at(5); - } - Q_ASSERT(!delimiter.isNull()); } /*! @@ -1155,7 +1131,7 @@ QVariant QDoubleSpinBoxPrivate::validateAndInterpret(QString &input, int &pos, state = max != min ? QValidator::Intermediate : QValidator::Invalid; goto end; case 1: - if (copy.at(0) == delimiter + if (copy.at(0) == locale.decimalPoint() || (plus && copy.at(0) == QLatin1Char('+')) || (minus && copy.at(0) == QLatin1Char('-'))) { state = QValidator::Intermediate; @@ -1163,7 +1139,7 @@ QVariant QDoubleSpinBoxPrivate::validateAndInterpret(QString &input, int &pos, } break; case 2: - if (copy.at(1) == delimiter + if (copy.at(1) == locale.decimalPoint() && ((plus && copy.at(0) == QLatin1Char('+')) || (minus && copy.at(0) == QLatin1Char('-')))) { state = QValidator::Intermediate; goto end; @@ -1172,14 +1148,14 @@ QVariant QDoubleSpinBoxPrivate::validateAndInterpret(QString &input, int &pos, default: break; } - if (copy.at(0) == thousand) { + if (copy.at(0) == locale.groupSeparator()) { QSBDEBUG() << __FILE__ << __LINE__<< "state is set to Invalid"; state = QValidator::Invalid; goto end; } else if (len > 1) { - const int dec = copy.indexOf(delimiter); + const int dec = copy.indexOf(locale.decimalPoint()); if (dec != -1) { - if (dec + 1 < copy.size() && copy.at(dec + 1) == delimiter && pos == dec + 1) { + if (dec + 1 < copy.size() && copy.at(dec + 1) == locale.decimalPoint() && pos == dec + 1) { copy.remove(dec + 1, 1); // typing a delimiter when you are on the delimiter } // should be treated as typing right arrow @@ -1189,7 +1165,7 @@ QVariant QDoubleSpinBoxPrivate::validateAndInterpret(QString &input, int &pos, goto end; } for (int i=dec + 1; i -1000 && copy.contains(thousand)) { + if (locale.groupSeparator().isPrint()) { + if (max < 1000 && min > -1000 && copy.contains(locale.groupSeparator())) { state = QValidator::Invalid; QSBDEBUG() << __FILE__ << __LINE__<< "state is set to Invalid"; goto end; @@ -1227,27 +1202,23 @@ QVariant QDoubleSpinBoxPrivate::validateAndInterpret(QString &input, int &pos, const int len = copy.size(); for (int i=0; i= min && num <= max) { - state = notAcceptable ? QValidator::Intermediate : QValidator::Acceptable; - QSBDEBUG() << __FILE__ << __LINE__<< "state is set to " - << (state == QValidator::Intermediate ? "Intermediate" : "Acceptable"); + state = QValidator::Acceptable; + QSBDEBUG() << __FILE__ << __LINE__<< "state is set to Acceptable"; } else if (max == min) { // when max and min is the same the only non-Invalid input is max (or min) state = QValidator::Invalid; QSBDEBUG() << __FILE__ << __LINE__<< "state is set to Invalid"; diff --git a/tests/auto/qdoublespinbox/tst_qdoublespinbox.cpp b/tests/auto/qdoublespinbox/tst_qdoublespinbox.cpp index 3d2fa42..7d7453b 100644 --- a/tests/auto/qdoublespinbox/tst_qdoublespinbox.cpp +++ b/tests/auto/qdoublespinbox/tst_qdoublespinbox.cpp @@ -147,6 +147,8 @@ private slots: void task221221(); void task255471_decimalsValidation(); + void taskQTBUG_5008_textFromValueAndValidate(); + public slots: void valueChangedHelper(const QString &); void valueChangedHelper(double); @@ -682,7 +684,7 @@ void tst_QDoubleSpinBox::valueFromTextAndValidate_data() QTest::newRow("data10") << QString(" 1") << Acceptable << 0.0 << 100.0 << (int)QLocale::Norwegian << QString("1"); QTest::newRow("data11") << QString(" 1") << Acceptable << 0.0 << 100.0 << (int)QLocale::C << QString("1"); QTest::newRow("data12") << QString("1,") << Acceptable << 0.0 << 100.0 << (int)QLocale::Norwegian << QString(); - QTest::newRow("data13") << QString("1,") << Intermediate << 0.0 << 1000.0 << (int)QLocale::C << QString(); + QTest::newRow("data13") << QString("1,") << Acceptable << 0.0 << 1000.0 << (int)QLocale::C << QString(); QTest::newRow("data14") << QString("1, ") << Acceptable << 0.0 << 100.0 << (int)QLocale::Norwegian << QString("1,"); QTest::newRow("data15") << QString("1, ") << Invalid << 0.0 << 100.0 << (int)QLocale::C << QString(); QTest::newRow("data16") << QString("2") << Intermediate << 100.0 << 102.0 << (int)QLocale::C << QString(); @@ -717,8 +719,8 @@ void tst_QDoubleSpinBox::valueFromTextAndValidate_data() QTest::newRow("data45") << QString("200,2") << Invalid << 0.0 << 1000.0 << (int)QLocale::C << QString(); QTest::newRow("data46") << QString("200,2") << Acceptable << 0.0 << 1000.0 << (int)QLocale::German << QString(); QTest::newRow("data47") << QString("2.2") << Acceptable << 0.0 << 1000.0 << (int)QLocale::C << QString(); - QTest::newRow("data48") << QString("2.2") << Intermediate << 0.0 << 1000.0 << (int)QLocale::German << QString(); - QTest::newRow("data49") << QString("2.2,00") << Intermediate << 0.0 << 1000.0 << (int)QLocale::German << QString(); + QTest::newRow("data48") << QString("2.2") << Acceptable << 0.0 << 1000.0 << (int)QLocale::German << QString(); + QTest::newRow("data49") << QString("2.2,00") << Acceptable << 0.0 << 1000.0 << (int)QLocale::German << QString(); QTest::newRow("data50") << QString("2.2") << Acceptable << 0.0 << 1000.0 << (int)QLocale::C << QString(); QTest::newRow("data51") << QString("2.2,00") << Invalid << 0.0 << 1000.0 << (int)QLocale::C << QString(); QTest::newRow("data52") << QString("2..2,00") << Invalid << 0.0 << 1000.0 << (int)QLocale::German << QString(); @@ -1044,6 +1046,36 @@ void tst_QDoubleSpinBox::task255471_decimalsValidation() } } +void tst_QDoubleSpinBox::taskQTBUG_5008_textFromValueAndValidate() +{ + class DecoratedSpinBox : public QDoubleSpinBox + { + friend class tst_QDoubleSpinBox; + public: + DecoratedSpinBox() + { + setLocale(QLocale::French); + setMaximum(100000000); + setValue(1000); + } + + //we use the French delimiters here + QString textFromValue (double value) const + { + return locale().toString(value); + } + } spinbox; + spinbox.show(); + spinbox.activateWindow(); + spinbox.setFocus(); + QTest::qWaitForWindowShown(&spinbox); + QCOMPARE(spinbox.text(), spinbox.locale().toString(spinbox.value())); + spinbox.lineEdit()->setCursorPosition(2); //just after the first thousand separator + QTest::keyClick(0, Qt::Key_0); // let's insert a 0 + QCOMPARE(spinbox.value(), 10000.); + spinbox.clearFocus(); //make sure the value is correctly formatted + QCOMPARE(spinbox.text(), spinbox.locale().toString(spinbox.value())); +} QTEST_MAIN(tst_QDoubleSpinBox) #include "tst_qdoublespinbox.moc" diff --git a/tests/auto/qspinbox/tst_qspinbox.cpp b/tests/auto/qspinbox/tst_qspinbox.cpp index 2389060..d2fe2ac 100644 --- a/tests/auto/qspinbox/tst_qspinbox.cpp +++ b/tests/auto/qspinbox/tst_qspinbox.cpp @@ -146,6 +146,8 @@ private slots: void sizeHint(); + void taskQTBUG_5008_textFromValueAndValidate(); + public slots: void valueChangedHelper(const QString &); void valueChangedHelper(int); @@ -1004,5 +1006,37 @@ void tst_QSpinBox::sizeHint() delete widget; } +void tst_QSpinBox::taskQTBUG_5008_textFromValueAndValidate() +{ + class DecoratedSpinBox : public QSpinBox + { + friend class tst_QSpinBox; + public: + DecoratedSpinBox() + { + setLocale(QLocale::French); + setMaximum(100000000); + setValue(1000000); + } + + //we use the French delimiters here + QString textFromValue (int value) const + { + return locale().toString(value); + } + } spinbox; + spinbox.show(); + spinbox.activateWindow(); + spinbox.setFocus(); + QTest::qWaitForWindowShown(&spinbox); + QCOMPARE(spinbox.text(), spinbox.locale().toString(spinbox.value())); + spinbox.lineEdit()->setCursorPosition(2); //just after the first thousand separator + QTest::keyClick(0, Qt::Key_0); // let's insert a 0 + QCOMPARE(spinbox.value(), 10000000); //it's been multiplied by 10 + spinbox.clearFocus(); //make sure the value is correctly formatted + QCOMPARE(spinbox.text(), spinbox.locale().toString(spinbox.value())); +} + + QTEST_MAIN(tst_QSpinBox) #include "tst_qspinbox.moc" -- cgit v0.12 From 41a8700c18b805d862c10847d29d30fd2d28911e Mon Sep 17 00:00:00 2001 From: Thierry Bastian Date: Wed, 25 Nov 2009 15:51:03 +0100 Subject: autotest fix: mac shows sizegrip when window is maximized --- tests/auto/qstatusbar/tst_qstatusbar.cpp | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/tests/auto/qstatusbar/tst_qstatusbar.cpp b/tests/auto/qstatusbar/tst_qstatusbar.cpp index 92d9185..03d8ca8 100644 --- a/tests/auto/qstatusbar/tst_qstatusbar.cpp +++ b/tests/auto/qstatusbar/tst_qstatusbar.cpp @@ -266,10 +266,15 @@ void tst_QStatusBar::QTBUG4334_hiddenOnMaximizedWindow() main.setStatusBar(&statusbar); main.showMaximized(); QTest::qWaitForWindowShown(&main); +#ifndef Q_WS_MAC QVERIFY(!statusbar.findChild()->isVisible()); +#endif main.showNormal(); QTest::qWaitForWindowShown(&main); QVERIFY(statusbar.findChild()->isVisible()); + main.showFullScreen(); + QTest::qWaitForWindowShown(&main); + QVERIFY(!statusbar.findChild()->isVisible()); } QTEST_MAIN(tst_QStatusBar) -- cgit v0.12 From d6f1feb5f0f639f9fb2deb5dc3758f5d6b7ad4d1 Mon Sep 17 00:00:00 2001 From: Alessandro Portale Date: Wed, 25 Nov 2009 16:29:34 +0100 Subject: Fixing background painting after orientation switch. Fixing previous fixes of QS60StylePrivate::setBackgroundTexture with commit SHAs a80e58335e69c8ce96d1596e0ed2d14e424a0d5e and d4089399a3ab7548a864d5a399e08df85c444783 Now, the palette gets the updated background brush and the palette is actually set as application palette. Also making sure that QS60StylePrivate::handleDynamicLayoutVariantSwitch does the right things in the right order. So that Table headers are not broken after orientaion switch. Task-number: QTBUG-6125 Task-number: QT-1478 --- src/gui/styles/qs60style.cpp | 1 + src/gui/styles/qs60style_s60.cpp | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/src/gui/styles/qs60style.cpp b/src/gui/styles/qs60style.cpp index 974c3ff..6c328b9 100644 --- a/src/gui/styles/qs60style.cpp +++ b/src/gui/styles/qs60style.cpp @@ -470,6 +470,7 @@ void QS60StylePrivate::setBackgroundTexture(QApplication *app) const QPalette applicationPalette = QApplication::palette(); applicationPalette.setBrush(QPalette::Window, backgroundTexture()); setThemePalette(&applicationPalette); + QApplication::setPalette(applicationPalette); } void QS60StylePrivate::deleteBackground() diff --git a/src/gui/styles/qs60style_s60.cpp b/src/gui/styles/qs60style_s60.cpp index a8dbf8d..48b8fad 100644 --- a/src/gui/styles/qs60style_s60.cpp +++ b/src/gui/styles/qs60style_s60.cpp @@ -1324,9 +1324,9 @@ QS60Style::QS60Style() void QS60StylePrivate::handleDynamicLayoutVariantSwitch() { clearCaches(QS60StylePrivate::CC_LayoutChange); + setBackgroundTexture(qApp); setActiveLayout(); refreshUI(); - setBackgroundTexture(qApp); foreach (QWidget *widget, QApplication::allWidgets()) widget->ensurePolished(); } -- cgit v0.12 From 5a180a11af102268d66f3822be256a1dc6980da4 Mon Sep 17 00:00:00 2001 From: Oswald Buddenhagen Date: Wed, 25 Nov 2009 16:58:50 +0100 Subject: qph: don't clobber fields the translator comment field is not written out, so reading the definition into it is basically discarding it as far as any roundtrips which arrive at qph again are concerned. the message's disambiguation seems most suitable for the task. Reviewed-by: hjk Task-number: QTBUG-4498 --- tools/linguist/shared/qph.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/linguist/shared/qph.cpp b/tools/linguist/shared/qph.cpp index 788245c..a364037 100644 --- a/tools/linguist/shared/qph.cpp +++ b/tools/linguist/shared/qph.cpp @@ -104,7 +104,7 @@ bool QPHReader::read(Translator &translator) TranslatorMessage msg; msg.setSourceText(m_currentSource); msg.setTranslation(m_currentTarget); - msg.setTranslatorComment(m_currentDefinition); + msg.setComment(m_currentDefinition); translator.append(msg); m_currentSource.clear(); m_currentTarget.clear(); -- cgit v0.12 From 69460da0a67c76f508bf4c32d14ce00304cdfd98 Mon Sep 17 00:00:00 2001 From: Oswald Buddenhagen Date: Wed, 25 Nov 2009 17:27:36 +0100 Subject: don't write context into field there is really no point in doing so Reviewed-by: hjk --- tools/linguist/shared/qph.cpp | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/tools/linguist/shared/qph.cpp b/tools/linguist/shared/qph.cpp index a364037..24148fd 100644 --- a/tools/linguist/shared/qph.cpp +++ b/tools/linguist/shared/qph.cpp @@ -166,9 +166,8 @@ static bool saveQPH(const Translator &translator, QIODevice &dev, ConversionData QChar(Translator::TextVariantSeparator)); t << " " << protect(str) << "\n"; - if (!msg.context().isEmpty() || !msg.comment().isEmpty()) - t << " " << msg.context() << msg.comment() - << "\n"; + if (!msg.comment().isEmpty()) + t << " " << msg.comment() << "\n"; t << "\n"; } t << "\n"; -- cgit v0.12 From 9554e641af877ee08eeae9adae4acf4d8b1d198d Mon Sep 17 00:00:00 2001 From: Oswald Buddenhagen Date: Wed, 25 Nov 2009 17:30:44 +0100 Subject: the definition needs xml escaping, too --- tools/linguist/shared/qph.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/linguist/shared/qph.cpp b/tools/linguist/shared/qph.cpp index 24148fd..fb4fee9 100644 --- a/tools/linguist/shared/qph.cpp +++ b/tools/linguist/shared/qph.cpp @@ -167,7 +167,7 @@ static bool saveQPH(const Translator &translator, QIODevice &dev, ConversionData t << " " << protect(str) << "\n"; if (!msg.comment().isEmpty()) - t << " " << msg.comment() << "\n"; + t << " " << protect(msg.comment()) << "\n"; t << "\n"; } t << "\n"; -- cgit v0.12 From 5776ff26ec44bc6d10cff2a8f81e81c33c39570a Mon Sep 17 00:00:00 2001 From: Kim Motoyoshi Kalland Date: Wed, 25 Nov 2009 17:13:30 +0100 Subject: Fixed round joins generated by the GL2 engine stroker. Complete circles were generated at every round join, so if the join were close to a flat cap, the circle would extend beyond the flat cap. This was fixed by generating arcs rather than complete circles. Likewise, round caps are now semi-circles instead of full circles. I also removed some unnecessary calculations when generating square caps. Reviewed-by: Trond --- .../gl2paintengineex/qtriangulatingstroker_p.h | 146 ++++++++++++++------- 1 file changed, 97 insertions(+), 49 deletions(-) diff --git a/src/opengl/gl2paintengineex/qtriangulatingstroker_p.h b/src/opengl/gl2paintengineex/qtriangulatingstroker_p.h index a0117d5..412e239 100644 --- a/src/opengl/gl2paintengineex/qtriangulatingstroker_p.h +++ b/src/opengl/gl2paintengineex/qtriangulatingstroker_p.h @@ -43,6 +43,7 @@ #define QTRIANGULATINGSTROKER_P_H #include +#include #include #include #include @@ -68,7 +69,7 @@ private: inline void join(const qreal *pts); inline void normalVector(float x1, float y1, float x2, float y2, float *nx, float *ny); inline void endCap(const qreal *pts); - inline void arc(float x, float y); + inline void arcPoints(float cx, float cy, float fromX, float fromY, float toX, float toY, QVarLengthArray &points); void endCapOrJoinClosed(const qreal *start, const qreal *cur, bool implicitClose, bool endsAtStart); @@ -149,43 +150,73 @@ inline void QTriangulatingStroker::emitLineSegment(float x, float y, float vx, f m_vertices.add(y - vy); } - - -// We draw a full circle for any round join or round cap which is a -// bit of overkill... -inline void QTriangulatingStroker::arc(float x, float y) +inline void QTriangulatingStroker::arcPoints(float cx, float cy, float fromX, float fromY, float toX, float toY, QVarLengthArray &points) { - float dx = m_width; - float dy = 0; - for (int i=0; i<=m_roundness; ++i) { - float tmpx = dx * m_cos_theta - dy * m_sin_theta; - float tmpy = dx * m_sin_theta + dy * m_cos_theta; - dx = tmpx; - dy = tmpy; - emitLineSegment(x, y, dx, dy); + float dx1 = fromX - cx; + float dy1 = fromY - cy; + float dx2 = toX - cx; + float dy2 = toY - cy; + + // while more than 180 degrees left: + while (dx1 * dy2 - dx2 * dy1 < 0) { + float tmpx = dx1 * m_cos_theta - dy1 * m_sin_theta; + float tmpy = dx1 * m_sin_theta + dy1 * m_cos_theta; + dx1 = tmpx; + dy1 = tmpy; + points.append(cx + dx1); + points.append(cy + dy1); } -} + // while more than 90 degrees left: + while (dx1 * dx2 + dy1 * dy2 < 0) { + float tmpx = dx1 * m_cos_theta - dy1 * m_sin_theta; + float tmpy = dx1 * m_sin_theta + dy1 * m_cos_theta; + dx1 = tmpx; + dy1 = tmpy; + points.append(cx + dx1); + points.append(cy + dy1); + } + + // while more than 0 degrees left: + while (dx1 * dy2 - dx2 * dy1 > 0) { + float tmpx = dx1 * m_cos_theta - dy1 * m_sin_theta; + float tmpy = dx1 * m_sin_theta + dy1 * m_cos_theta; + dx1 = tmpx; + dy1 = tmpy; + points.append(cx + dx1); + points.append(cy + dy1); + } + // remove last point which was rotated beyond [toX, toY]. + if (!points.isEmpty()) + points.resize(points.size() - 2); +} -inline void QTriangulatingStroker::endCap(const qreal *pts) +inline void QTriangulatingStroker::endCap(const qreal *) { switch (m_cap_style) { case Qt::FlatCap: break; - case Qt::SquareCap: { - float dx = m_cx - *(pts - 2); - float dy = m_cy - *(pts - 1); - - float len = m_width / sqrt(dx * dx + dy * dy); - dx = dx * len; - dy = dy * len; - - emitLineSegment(m_cx + dx, m_cy + dy, m_nvx, m_nvy); - break; } - case Qt::RoundCap: - arc(m_cx, m_cy); + case Qt::SquareCap: + emitLineSegment(m_cx + m_nvy, m_cy - m_nvx, m_nvx, m_nvy); break; + case Qt::RoundCap: { + QVarLengthArray points; + int count = m_vertices.size(); + arcPoints(m_cx, m_cy, m_vertices.at(count - 2), m_vertices.at(count - 1), m_vertices.at(count - 4), m_vertices.at(count - 3), points); + int front = 0; + int end = points.size() / 2; + while (front != end) { + m_vertices.add(points[2 * end - 2]); + m_vertices.add(points[2 * end - 1]); + --end; + if (front == end) + break; + m_vertices.add(points[2 * front + 0]); + m_vertices.add(points[2 * front + 1]); + ++front; + } + break; } default: break; // to shut gcc up... } } @@ -214,31 +245,37 @@ void QTriangulatingStroker::moveTo(const qreal *pts) } break; case Qt::SquareCap: { - float dx = x2 - m_cx; - float dy = y2 - m_cy; - float len = m_width / sqrt(dx * dx + dy * dy); - dx = dx * len; - dy = dy * len; - float sx = m_cx - dx; - float sy = m_cy - dy; + float sx = m_cx - m_nvy; + float sy = m_cy + m_nvx; if (invisibleJump) { m_vertices.add(sx + m_nvx); m_vertices.add(sy + m_nvy); } emitLineSegment(sx, sy, m_nvx, m_nvy); break; } - case Qt::RoundCap: - if (invisibleJump) { - m_vertices.add(m_cx + m_nvx); - m_vertices.add(m_cy + m_nvy); + case Qt::RoundCap: { + QVarLengthArray points; + arcPoints(m_cx, m_cy, m_cx + m_nvx, m_cy + m_nvy, m_cx - m_nvx, m_cy - m_nvy, points); + m_vertices.resize(m_vertices.size() + points.size() + 2 * int(invisibleJump)); + int count = m_vertices.size(); + int front = 0; + int end = points.size() / 2; + while (front != end) { + m_vertices.at(--count) = points[2 * end - 1]; + m_vertices.at(--count) = points[2 * end - 2]; + --end; + if (front == end) + break; + m_vertices.at(--count) = points[2 * front + 1]; + m_vertices.at(--count) = points[2 * front + 0]; + ++front; } - // This emitLineSegment is not needed for the arc, but we need - // to start where we put the invisibleJump vertex, otherwise - // we'll have visible triangles between subpaths. - emitLineSegment(m_cx, m_cy, m_nvx, m_nvy); - arc(m_cx, m_cy); - break; + if (invisibleJump) { + m_vertices.at(count - 1) = m_vertices.at(count + 1); + m_vertices.at(count - 2) = m_vertices.at(count + 0); + } + break; } default: break; // ssssh gcc... } emitLineSegment(m_cx, m_cy, m_nvx, m_nvy); @@ -289,10 +326,21 @@ void QTriangulatingStroker::join(const qreal *pts) // what some other graphics API's do. break; } - case Qt::RoundJoin: - arc(m_cx, m_cy); - break; - + case Qt::RoundJoin: { + QVarLengthArray points; + int count = m_vertices.size(); + float prevNvx = m_vertices.at(count - 2) - m_cx; + float prevNvy = m_vertices.at(count - 1) - m_cy; + if (m_nvx * prevNvy - m_nvy * prevNvx < 0) { + arcPoints(0, 0, m_nvx, m_nvy, -prevNvx, -prevNvy, points); + for (int i = points.size() / 2; i > 0; --i) + emitLineSegment(m_cx, m_cy, points[2 * i - 2], points[2 * i - 1]); + } else { + arcPoints(0, 0, -prevNvx, -prevNvy, m_nvx, m_nvy, points); + for (int i = 0; i < points.size() / 2; ++i) + emitLineSegment(m_cx, m_cy, points[2 * i + 0], points[2 * i + 1]); + } + break; } default: break; // gcc warn-- } -- cgit v0.12 From dab1b98d84293e863c920add25980393fad2e9cd Mon Sep 17 00:00:00 2001 From: Alessandro Portale Date: Wed, 25 Nov 2009 17:41:34 +0100 Subject: Fixing background painting after orientation switch. Fixing previous fixes of QS60StylePrivate::setBackgroundTexture with commit SHAs a80e58335e69c8ce96d1596e0ed2d14e424a0d5e and d4089399a3ab7548a864d5a399e08df85c444783 Now, the palette gets the updated background brush and the palette is actually set as application palette. Also making sure that QS60StylePrivate::handleDynamicLayoutVariantSwitch does the right things in the right order. So that Table headers are not broken after orientaion switch. Task-number: QTBUG-6125 Task-number: QT-1478 Reviewed-by: Shane Kearns --- src/gui/styles/qs60style.cpp | 1 + src/gui/styles/qs60style_s60.cpp | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/src/gui/styles/qs60style.cpp b/src/gui/styles/qs60style.cpp index b5c0d4f..2137244 100644 --- a/src/gui/styles/qs60style.cpp +++ b/src/gui/styles/qs60style.cpp @@ -475,6 +475,7 @@ void QS60StylePrivate::setBackgroundTexture(QApplication *app) const QPalette applicationPalette = QApplication::palette(); applicationPalette.setBrush(QPalette::Window, backgroundTexture()); setThemePalette(&applicationPalette); + QApplication::setPalette(applicationPalette); } void QS60StylePrivate::deleteBackground() diff --git a/src/gui/styles/qs60style_s60.cpp b/src/gui/styles/qs60style_s60.cpp index a8dbf8d..48b8fad 100644 --- a/src/gui/styles/qs60style_s60.cpp +++ b/src/gui/styles/qs60style_s60.cpp @@ -1324,9 +1324,9 @@ QS60Style::QS60Style() void QS60StylePrivate::handleDynamicLayoutVariantSwitch() { clearCaches(QS60StylePrivate::CC_LayoutChange); + setBackgroundTexture(qApp); setActiveLayout(); refreshUI(); - setBackgroundTexture(qApp); foreach (QWidget *widget, QApplication::allWidgets()) widget->ensurePolished(); } -- cgit v0.12 From aae664552f7e5fba96ab6f334ec354800ad83c06 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bj=C3=B8rn=20Erik=20Nilsen?= Date: Wed, 25 Nov 2009 10:27:25 +0100 Subject: Remove caching of QGraphicsItem::clipPath(). The cache was added in 4.5 and was useful at that time. With 4.6 it is not relevant anymore since the only use case for it is item-lookup releated to mouse events and collision detection, so the overhead of maintaining the cache is more pain than gain. All existing auto tests pass. --- src/gui/graphicsview/qgraphicsitem.cpp | 165 ++----------------------------- src/gui/graphicsview/qgraphicsitem_p.h | 32 +----- src/gui/graphicsview/qgraphicswidget.cpp | 2 - 3 files changed, 8 insertions(+), 191 deletions(-) diff --git a/src/gui/graphicsview/qgraphicsitem.cpp b/src/gui/graphicsview/qgraphicsitem.cpp index 710048e..a42c1c3 100644 --- a/src/gui/graphicsview/qgraphicsitem.cpp +++ b/src/gui/graphicsview/qgraphicsitem.cpp @@ -755,7 +755,6 @@ void QGraphicsItemPrivate::updateAncestorFlag(QGraphicsItem::GraphicsItemFlag ch case QGraphicsItem::ItemClipsChildrenToShape: flag = AncestorClipsChildren; enabled = flags & QGraphicsItem::ItemClipsChildrenToShape; - invalidateCachedClipPathRecursively(/*childrenOnly=*/true); break; case QGraphicsItem::ItemIgnoresTransformations: flag = AncestorIgnoresTransformations; @@ -1732,9 +1731,6 @@ void QGraphicsItem::setFlags(GraphicsItemFlags flags) d_ptr->updateAncestorFlag(ItemClipsChildrenToShape); } - if ((flags & ItemClipsToShape) != (oldFlags & ItemClipsToShape)) - d_ptr->invalidateCachedClipPath(); - if ((flags & ItemIgnoresTransformations) != (oldFlags & ItemIgnoresTransformations)) { // Item children clipping changes. Propagate the ancestor flag to // all children. @@ -3399,7 +3395,6 @@ void QGraphicsItemPrivate::setPosHelper(const QPointF &pos) { Q_Q(QGraphicsItem); inSetPosHelper = 1; - updateCachedClipPathFromSetPosHelper(pos); if (scene) q->prepareGeometryChange(); QPointF oldPos = this->pos; @@ -4535,22 +4530,12 @@ bool QGraphicsItem::isClipped() const QPainterPath QGraphicsItem::clipPath() const { Q_D(const QGraphicsItem); - if (!d->dirtyClipPath) - return d->emptyClipPath ? QPainterPath() : d->cachedClipPath; - - if (!isClipped()) { - d_ptr->setCachedClipPath(QPainterPath()); - return d->cachedClipPath; - } + if (!isClipped()) + return QPainterPath(); const QRectF thisBoundingRect(boundingRect()); - if (thisBoundingRect.isEmpty()) { - if (d_ptr->flags & ItemClipsChildrenToShape) - d_ptr->setEmptyCachedClipPathRecursively(); - else - d_ptr->setEmptyCachedClipPath(); + if (thisBoundingRect.isEmpty()) return QPainterPath(); - } QPainterPath clip; // Start with the item's bounding rect. @@ -4561,40 +4546,18 @@ QPainterPath QGraphicsItem::clipPath() const const QGraphicsItem *lastParent = this; // Intersect any in-between clips starting at the top and moving downwards. - bool foundValidClipPath = false; while ((parent = parent->d_ptr->parent)) { if (parent->d_ptr->flags & ItemClipsChildrenToShape) { // Map clip to the current parent and intersect with its shape/clipPath clip = lastParent->itemTransform(parent).map(clip); - if ((foundValidClipPath = !parent->d_ptr->dirtyClipPath && parent->isClipped())) { - if (parent->d_ptr->emptyClipPath) { - if (d_ptr->flags & ItemClipsChildrenToShape) - d_ptr->setEmptyCachedClipPathRecursively(); - else - d_ptr->setEmptyCachedClipPath(); - return QPainterPath(); - } - clip = clip.intersected(parent->d_ptr->cachedClipPath); - if (!(parent->d_ptr->flags & ItemClipsToShape)) - clip = clip.intersected(parent->shape()); - } else { - clip = clip.intersected(parent->shape()); - } - - if (clip.isEmpty()) { - if (d_ptr->flags & ItemClipsChildrenToShape) - d_ptr->setEmptyCachedClipPathRecursively(); - else - d_ptr->setEmptyCachedClipPath(); + clip = clip.intersected(parent->shape()); + if (clip.isEmpty()) return clip; - } lastParent = parent; } - if (!(parent->d_ptr->ancestorFlags & QGraphicsItemPrivate::AncestorClipsChildren) - || foundValidClipPath) { + if (!(parent->d_ptr->ancestorFlags & QGraphicsItemPrivate::AncestorClipsChildren)) break; - } } if (lastParent != this) { @@ -4607,7 +4570,6 @@ QPainterPath QGraphicsItem::clipPath() const if (d->flags & ItemClipsToShape) clip = clip.intersected(shape()); - d_ptr->setCachedClipPath(clip); return clip; } @@ -5029,12 +4991,12 @@ void QGraphicsItem::setBoundingRegionGranularity(qreal granularity) bool QGraphicsItemPrivate::discardUpdateRequest(bool ignoreClipping, bool ignoreVisibleBit, bool ignoreDirtyBit, bool ignoreOpacity) const { + Q_UNUSED(ignoreClipping); // No scene, or if the scene is updating everything, means we have nothing // to do. The only exception is if the scene tracks the growing scene rect. return !scene || (!visible && !ignoreVisibleBit && !this->ignoreVisible) || (!ignoreDirtyBit && fullUpdatePending) - || (!ignoreClipping && (childrenClippedToShape() && isClippedAway())) || (!ignoreOpacity && !this->ignoreOpacity && childrenCombineOpacity() && isFullyTransparent()); } @@ -5169,109 +5131,6 @@ void QGraphicsItemPrivate::removeExtraItemCache() unsetExtra(ExtraCacheData); } -void QGraphicsItemPrivate::setEmptyCachedClipPathRecursively(const QRectF &emptyIfOutsideThisRect) -{ - setEmptyCachedClipPath(); - - const bool checkRect = !emptyIfOutsideThisRect.isNull() - && !(flags & QGraphicsItem::ItemClipsChildrenToShape); - for (int i = 0; i < children.size(); ++i) { - if (!checkRect) { - children.at(i)->d_ptr->setEmptyCachedClipPathRecursively(); - continue; - } - - QGraphicsItem *child = children.at(i); - const QRectF rect = child->mapRectFromParent(emptyIfOutsideThisRect); - if (rect.intersects(child->boundingRect())) - child->d_ptr->invalidateCachedClipPathRecursively(false, rect); - else - child->d_ptr->setEmptyCachedClipPathRecursively(rect); - } -} - -void QGraphicsItemPrivate::invalidateCachedClipPathRecursively(bool childrenOnly, const QRectF &emptyIfOutsideThisRect) -{ - if (!childrenOnly) - invalidateCachedClipPath(); - - const bool checkRect = !emptyIfOutsideThisRect.isNull(); - for (int i = 0; i < children.size(); ++i) { - if (!checkRect) { - children.at(i)->d_ptr->invalidateCachedClipPathRecursively(false); - continue; - } - - QGraphicsItem *child = children.at(i); - const QRectF rect = child->mapRectFromParent(emptyIfOutsideThisRect); - if (rect.intersects(child->boundingRect())) - child->d_ptr->invalidateCachedClipPathRecursively(false, rect); - else - child->d_ptr->setEmptyCachedClipPathRecursively(rect); - } -} - -void QGraphicsItemPrivate::updateCachedClipPathFromSetPosHelper(const QPointF &newPos) -{ - Q_ASSERT(inSetPosHelper); - - if (inDestructor || !(ancestorFlags & QGraphicsItemPrivate::AncestorClipsChildren)) - return; // Not clipped by any ancestor. - - // Find closest clip ancestor and transform. - Q_Q(QGraphicsItem); - // COMBINE - QTransform thisToParentTransform = QTransform::fromTranslate(newPos.x(), newPos.y()); - if (transformData) - thisToParentTransform = transformData->computedFullTransform(&thisToParentTransform); - QGraphicsItem *clipParent = parent; - while (clipParent && !clipParent->d_ptr->inDestructor && !(clipParent->d_ptr->flags & QGraphicsItem::ItemClipsChildrenToShape)) { - thisToParentTransform *= clipParent->d_ptr->transformToParent(); - clipParent = clipParent->d_ptr->parent; - } - - // Ensure no parents are currently being deleted. This can only - // happen if the item is moved by a dying ancestor. - QGraphicsItem *p = clipParent; - while (p) { - if (p->d_ptr->inDestructor) - return; - p = p->d_ptr->parent; - } - - // From here everything is calculated in clip parent's coordinates. - const QRectF parentBoundingRect(clipParent->boundingRect()); - const QRectF thisBoundingRect(thisToParentTransform.mapRect(q->boundingRect())); - - if (!parentBoundingRect.intersects(thisBoundingRect)) { - // Item is moved outside the clip parent's bounding rect, - // i.e. it is fully clipped and the clip path is empty. - if (flags & QGraphicsItem::ItemClipsChildrenToShape) - setEmptyCachedClipPathRecursively(); - else - setEmptyCachedClipPathRecursively(thisToParentTransform.inverted().mapRect(parentBoundingRect)); - return; - } - - const QPainterPath parentClip(clipParent->isClipped() ? clipParent->clipPath() : clipParent->shape()); - if (parentClip.contains(thisBoundingRect)) - return; // Item is inside the clip parent's shape. No update required. - - const QRectF parentClipRect(parentClip.controlPointRect()); - if (!parentClipRect.intersects(thisBoundingRect)) { - // Item is moved outside the clip parent's shape, - // i.e. it is fully clipped and the clip path is empty. - if (flags & QGraphicsItem::ItemClipsChildrenToShape) - setEmptyCachedClipPathRecursively(); - else - setEmptyCachedClipPathRecursively(thisToParentTransform.inverted().mapRect(parentClipRect)); - } else { - // Item is partially inside the clip parent's shape, - // i.e. the cached clip path must be invalidated. - invalidateCachedClipPathRecursively(false, thisToParentTransform.inverted().mapRect(parentClipRect)); - } -} - // Traverses all the ancestors up to the top-level and updates the pointer to // always point to the top-most item that has a dirty scene transform. // It then backtracks to the top-most dirty item and start calculating the @@ -7313,16 +7172,6 @@ void QGraphicsItem::prepareGeometryChange() // ### Only do this if the parent's effect applies to the entire subtree. parent->d_ptr->notifyBoundingRectChanged = 1; } - - if (d_ptr->inSetPosHelper) - return; - - if (d_ptr->flags & ItemClipsChildrenToShape - || d_ptr->ancestorFlags & QGraphicsItemPrivate::AncestorClipsChildren) { - d_ptr->invalidateCachedClipPathRecursively(); - } else { - d_ptr->invalidateCachedClipPath(); - } } /*! diff --git a/src/gui/graphicsview/qgraphicsitem_p.h b/src/gui/graphicsview/qgraphicsitem_p.h index 75c8246..013fce1 100644 --- a/src/gui/graphicsview/qgraphicsitem_p.h +++ b/src/gui/graphicsview/qgraphicsitem_p.h @@ -152,8 +152,6 @@ public: dirty(0), dirtyChildren(0), localCollisionHack(0), - dirtyClipPath(1), - emptyClipPath(0), inSetPosHelper(0), needSortChildren(1), // ### can be 0 by default? allChildrenDirty(0), @@ -307,26 +305,6 @@ public: QGraphicsItemCache *extraItemCache() const; void removeExtraItemCache(); - inline void setCachedClipPath(const QPainterPath &path) - { - cachedClipPath = path; - dirtyClipPath = 0; - emptyClipPath = 0; - } - - inline void setEmptyCachedClipPath() - { - emptyClipPath = 1; - dirtyClipPath = 0; - } - - void setEmptyCachedClipPathRecursively(const QRectF &emptyIfOutsideThisRect = QRectF()); - - inline void invalidateCachedClipPath() - { /*static int count = 0 ;qWarning("%i", ++count);*/ dirtyClipPath = 1; emptyClipPath = 0; } - - void invalidateCachedClipPathRecursively(bool childrenOnly = false, const QRectF &emptyIfOutsideThisRect = QRectF()); - void updateCachedClipPathFromSetPosHelper(const QPointF &newPos); void ensureSceneTransformRecursive(QGraphicsItem **topMostDirtyItem); inline void ensureSceneTransform() { @@ -409,17 +387,12 @@ public: return true; } - inline bool isClippedAway() const - { return !dirtyClipPath && q_func()->isClipped() && (emptyClipPath || cachedClipPath.isEmpty()); } - inline bool childrenClippedToShape() const { return (flags & QGraphicsItem::ItemClipsChildrenToShape) || children.isEmpty(); } inline bool isInvisible() const { - return !visible - || (childrenClippedToShape() && isClippedAway()) - || (childrenCombineOpacity() && isFullyTransparent()); + return !visible || (childrenCombineOpacity() && isFullyTransparent()); } void setFocusHelper(Qt::FocusReason focusReason, bool climb); @@ -435,7 +408,6 @@ public: inline void sendScenePosChange(); virtual void siblingOrderChange(); - QPainterPath cachedClipPath; QRectF childrenBoundingRect; QRectF needsRepaint; QMap paintedViewBoundingRects; @@ -480,8 +452,6 @@ public: quint32 dirty : 1; quint32 dirtyChildren : 1; quint32 localCollisionHack : 1; - quint32 dirtyClipPath : 1; - quint32 emptyClipPath : 1; quint32 inSetPosHelper : 1; quint32 needSortChildren : 1; quint32 allChildrenDirty : 1; diff --git a/src/gui/graphicsview/qgraphicswidget.cpp b/src/gui/graphicsview/qgraphicswidget.cpp index d9c65bb..f6c06d5 100644 --- a/src/gui/graphicsview/qgraphicswidget.cpp +++ b/src/gui/graphicsview/qgraphicswidget.cpp @@ -385,8 +385,6 @@ void QGraphicsWidget::setGeometry(const QRectF &rect) QSizeF oldSize = size(); QGraphicsLayoutItem::setGeometry(newGeom); - wd->invalidateCachedClipPathRecursively(); - // Send resize event bool resized = newGeom.size() != oldSize; if (resized) { -- cgit v0.12 From 9638c1e076a6dac73dd6a5a4ffee10b1c71eedcb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bj=C3=B8rn=20Erik=20Nilsen?= Date: Wed, 25 Nov 2009 11:53:10 +0100 Subject: Remove unused variables in QGraphicsItem and QGraphicsScene. maybeDirtyClipPath and ingoreClipping is not relevant anymore now that the cached clip path is removed. --- src/gui/graphicsview/qgraphicsitem.cpp | 40 ++++++++++++--------------------- src/gui/graphicsview/qgraphicsitem_p.h | 2 +- src/gui/graphicsview/qgraphicsscene.cpp | 9 ++++---- src/gui/graphicsview/qgraphicsscene_p.h | 3 +-- 4 files changed, 20 insertions(+), 34 deletions(-) diff --git a/src/gui/graphicsview/qgraphicsitem.cpp b/src/gui/graphicsview/qgraphicsitem.cpp index a42c1c3..34f42fb 100644 --- a/src/gui/graphicsview/qgraphicsitem.cpp +++ b/src/gui/graphicsview/qgraphicsitem.cpp @@ -1103,9 +1103,7 @@ void QGraphicsItemPrivate::setParentItemHelper(QGraphicsItem *newParent) parent->itemChange(QGraphicsItem::ItemChildAddedChange, thisPointerVariant); if (scene) { if (!implicitUpdate) - scene->d_func()->markDirty(q_ptr, QRect(), - /*invalidateChildren=*/false, - /*maybeDirtyClipPath=*/true); + scene->d_func()->markDirty(q_ptr); // Re-enable scene pos notifications for new ancestors if (scenePosDescendants || (flags & QGraphicsItem::ItemSendsScenePositionChanges)) @@ -1146,11 +1144,8 @@ void QGraphicsItemPrivate::setParentItemHelper(QGraphicsItem *newParent) setEnabledHelper(true, /* explicit = */ false); // If the item is being deleted, the whole scene will be updated. - if (scene) { - scene->d_func()->markDirty(q_ptr, QRect(), - /*invalidateChildren=*/false, - /*maybeDirtyClipPath=*/true); - } + if (scene) + scene->d_func()->markDirty(q_ptr); } } @@ -1773,9 +1768,7 @@ void QGraphicsItem::setFlags(GraphicsItemFlags flags) else d_ptr->scene->d_func()->unregisterScenePosItem(this); } - d_ptr->scene->d_func()->markDirty(this, QRectF(), - /*invalidateChildren=*/true, - /*maybeDirtyClipPath*/true); + d_ptr->scene->d_func()->markDirty(this, QRectF(), /*invalidateChildren=*/true); } // Notify change. @@ -2123,12 +2116,8 @@ void QGraphicsItemPrivate::setVisibleHelper(bool newVisible, bool explicitly, bo QGraphicsItemCache *c = (QGraphicsItemCache *)qVariantValue(extra(ExtraCacheData)); if (c) c->purge(); - if (scene) { - scene->d_func()->markDirty(q_ptr, QRectF(), - /*invalidateChildren=*/false, - /*maybeDirtyClipPath=*/false, - /*force=*/true); - } + if (scene) + scene->d_func()->markDirty(q_ptr, QRectF(), /*invalidateChildren=*/false, /*force=*/true); } // Certain properties are dropped as an item becomes invisible. @@ -2538,7 +2527,6 @@ void QGraphicsItem::setOpacity(qreal opacity) #endif //QT_NO_GRAPHICSEFFECT d_ptr->scene->d_func()->markDirty(this, QRectF(), /*invalidateChildren=*/true, - /*maybeDirtyClipPath=*/false, /*force=*/false, /*ignoreOpacity=*/true); } @@ -2586,8 +2574,11 @@ void QGraphicsItem::setGraphicsEffect(QGraphicsEffect *effect) d_ptr->graphicsEffect = 0; if (oldEffectPrivate) { oldEffectPrivate->setGraphicsEffectSource(0); // deletes the current source. - if (d_ptr->scene) // Update the views directly. - d_ptr->scene->d_func()->markDirty(this, QRectF(), false, false, false, false, true); + if (d_ptr->scene) { // Update the views directly. + d_ptr->scene->d_func()->markDirty(this, QRectF(), /*invalidateChildren=*/false, + /*force=*/false, /*ignoreOpacity=*/false, + /*removeItemFromScene=*/true); + } } } else { // Set new effect. @@ -4988,10 +4979,9 @@ void QGraphicsItem::setBoundingRegionGranularity(qreal granularity) \internal Returns true if we can discard an update request; otherwise false. */ -bool QGraphicsItemPrivate::discardUpdateRequest(bool ignoreClipping, bool ignoreVisibleBit, - bool ignoreDirtyBit, bool ignoreOpacity) const +bool QGraphicsItemPrivate::discardUpdateRequest(bool ignoreVisibleBit, bool ignoreDirtyBit, + bool ignoreOpacity) const { - Q_UNUSED(ignoreClipping); // No scene, or if the scene is updating everything, means we have nothing // to do. The only exception is if the scene tracks the growing scene rect. return !scene @@ -7147,9 +7137,7 @@ void QGraphicsItem::prepareGeometryChange() QGraphicsScenePrivate *scenePrivate = d_ptr->scene->d_func(); scenePrivate->index->prepareBoundingRectChange(this); - scenePrivate->markDirty(this, QRectF(), - /*invalidateChildren=*/true, - /*maybeDirtyClipPath=*/!d_ptr->inSetPosHelper); + scenePrivate->markDirty(this, QRectF(), /*invalidateChildren=*/true); // For compatibility reasons, we have to update the item's old geometry // if someone is connected to the changed signal or the scene has no views. diff --git a/src/gui/graphicsview/qgraphicsitem_p.h b/src/gui/graphicsview/qgraphicsitem_p.h index 013fce1..d6ffb1a 100644 --- a/src/gui/graphicsview/qgraphicsitem_p.h +++ b/src/gui/graphicsview/qgraphicsitem_p.h @@ -219,7 +219,7 @@ public: void appendGraphicsTransform(QGraphicsTransform *t); void setVisibleHelper(bool newVisible, bool explicitly, bool update = true); void setEnabledHelper(bool newEnabled, bool explicitly, bool update = true); - bool discardUpdateRequest(bool ignoreClipping = false, bool ignoreVisibleBit = false, + bool discardUpdateRequest(bool ignoreVisibleBit = false, bool ignoreDirtyBit = false, bool ignoreOpacity = false) const; int depth() const; #ifndef QT_NO_GRAPHICSEFFECT diff --git a/src/gui/graphicsview/qgraphicsscene.cpp b/src/gui/graphicsview/qgraphicsscene.cpp index 10d251d..8777cdc 100644 --- a/src/gui/graphicsview/qgraphicsscene.cpp +++ b/src/gui/graphicsview/qgraphicsscene.cpp @@ -555,7 +555,8 @@ void QGraphicsScenePrivate::removeItemHelper(QGraphicsItem *item) // Clear focus on the item to remove any reference in the focusWidget chain. item->clearFocus(); - markDirty(item, QRectF(), false, false, false, false, /*removingItemFromScene=*/true); + markDirty(item, QRectF(), /*invalidateChildren=*/false, /*force=*/false, + /*ignoreOpacity=*/false, /*removingItemFromScene=*/true); if (item->d_ptr->inDestructor) { // The item is actually in its destructor, we call the special method in the index. @@ -4759,15 +4760,13 @@ void QGraphicsScenePrivate::draw(QGraphicsItem *item, QPainter *painter, const Q } void QGraphicsScenePrivate::markDirty(QGraphicsItem *item, const QRectF &rect, bool invalidateChildren, - bool maybeDirtyClipPath, bool force, bool ignoreOpacity, - bool removingItemFromScene) + bool force, bool ignoreOpacity, bool removingItemFromScene) { Q_ASSERT(item); if (updateAll) return; - if (item->d_ptr->discardUpdateRequest(/*ignoreClipping=*/maybeDirtyClipPath, - /*ignoreVisibleBit=*/force, + if (item->d_ptr->discardUpdateRequest(/*ignoreVisibleBit=*/force, /*ignoreDirtyBit=*/removingItemFromScene || invalidateChildren, /*ignoreOpacity=*/ignoreOpacity)) { if (item->d_ptr->dirty) { diff --git a/src/gui/graphicsview/qgraphicsscene_p.h b/src/gui/graphicsview/qgraphicsscene_p.h index fdec466..a1d0496 100644 --- a/src/gui/graphicsview/qgraphicsscene_p.h +++ b/src/gui/graphicsview/qgraphicsscene_p.h @@ -222,8 +222,7 @@ public: QRegion *, QWidget *, qreal, const QTransform *const, bool, bool); void markDirty(QGraphicsItem *item, const QRectF &rect = QRectF(), bool invalidateChildren = false, - bool maybeDirtyClipPath = false, bool force = false, bool ignoreOpacity = false, - bool removingItemFromScene = false); + bool force = false, bool ignoreOpacity = false, bool removingItemFromScene = false); void processDirtyItemsRecursive(QGraphicsItem *item, bool dirtyAncestorContainsChildren = false, qreal parentOpacity = qreal(1.0)); -- cgit v0.12 From 729d01352f7c6165228eab9e32d52becbb4258a5 Mon Sep 17 00:00:00 2001 From: Oswald Buddenhagen Date: Wed, 25 Nov 2009 20:53:21 +0100 Subject: make qph use language attributes --- tools/linguist/shared/qph.cpp | 23 ++++++++++++++++++----- 1 file changed, 18 insertions(+), 5 deletions(-) diff --git a/tools/linguist/shared/qph.cpp b/tools/linguist/shared/qph.cpp index fb4fee9..32bdabb 100644 --- a/tools/linguist/shared/qph.cpp +++ b/tools/linguist/shared/qph.cpp @@ -81,14 +81,20 @@ bool QPHReader::read(Translator &translator) while (!atEnd()) { readNext(); if (isStartElement()) { - if (name() == QLatin1String("source")) + if (name() == QLatin1String("source")) { m_currentField = SourceField; - else if (name() == QLatin1String("target")) + } else if (name() == QLatin1String("target")) { m_currentField = TargetField; - else if (name() == QLatin1String("definition")) + } else if (name() == QLatin1String("definition")) { m_currentField = DefinitionField; - else + } else { m_currentField = NoField; + if (name() == QLatin1String("QPH")) { + QXmlStreamAttributes atts = attributes(); + translator.setLanguageCode(atts.value(QLatin1String("language")).toString()); + translator.setSourceLanguageCode(atts.value(QLatin1String("sourcelanguage")).toString()); + } + } } else if (isWhiteSpace()) { // ignore these } else if (isCharacters()) { @@ -157,7 +163,14 @@ static bool saveQPH(const Translator &translator, QIODevice &dev, ConversionData { QTextStream t(&dev); t.setCodec(QTextCodec::codecForName("UTF-8")); - t << "\n\n"; + t << "\n\n"; foreach (const TranslatorMessage &msg, translator.messages()) { t << "\n"; t << " " << protect(msg.sourceText()) << "\n"; -- cgit v0.12 From 67e031b196745e44a2edb608e18ddd8f5722d91b Mon Sep 17 00:00:00 2001 From: Oswald Buddenhagen Date: Wed, 25 Nov 2009 20:52:55 +0100 Subject: add qph autotest --- tests/auto/linguist/lconvert/data/phrasebook.qph | 21 +++++++++++++++++++++ tests/auto/linguist/lconvert/tst_lconvert.cpp | 1 + 2 files changed, 22 insertions(+) create mode 100644 tests/auto/linguist/lconvert/data/phrasebook.qph diff --git a/tests/auto/linguist/lconvert/data/phrasebook.qph b/tests/auto/linguist/lconvert/data/phrasebook.qph new file mode 100644 index 0000000..847a53b --- /dev/null +++ b/tests/auto/linguist/lconvert/data/phrasebook.qph @@ -0,0 +1,21 @@ + + + + About + Info + + + adornment + Zubehör + + + barrel button + Pen-Knopf + pen + + + foo & bar + Foo & bar + <test>übergroß + + diff --git a/tests/auto/linguist/lconvert/tst_lconvert.cpp b/tests/auto/linguist/lconvert/tst_lconvert.cpp index 10098a4..cf8f5c3 100644 --- a/tests/auto/linguist/lconvert/tst_lconvert.cpp +++ b/tests/auto/linguist/lconvert/tst_lconvert.cpp @@ -213,6 +213,7 @@ void tst_lconvert::readverifies_data() QTest::newRow("relative locations") << "relative.ts" << "ts"; QTest::newRow("message ids") << "msgid.ts" << "ts"; QTest::newRow("length variants") << "variants.ts" << "ts"; + QTest::newRow("qph") << "phrasebook.qph" << "qph"; } void tst_lconvert::readverifies() -- cgit v0.12 From f1ae6d0ecba250d83cf7e747868af32ceadc085f Mon Sep 17 00:00:00 2001 From: Oswald Buddenhagen Date: Wed, 25 Nov 2009 23:12:26 +0100 Subject: offer only possible countries for each language otherwise qlocale will silently clobber the user's (most probably bogus) choice anyway. --- .../linguist/translationsettingsdialog.cpp | 33 ++++++++++++++++------ .../linguist/linguist/translationsettingsdialog.h | 2 ++ 2 files changed, 27 insertions(+), 8 deletions(-) diff --git a/tools/linguist/linguist/translationsettingsdialog.cpp b/tools/linguist/linguist/translationsettingsdialog.cpp index 0d94c3a..562f14e 100644 --- a/tools/linguist/linguist/translationsettingsdialog.cpp +++ b/tools/linguist/linguist/translationsettingsdialog.cpp @@ -60,15 +60,7 @@ TranslationSettingsDialog::TranslationSettingsDialog(QWidget *parent) m_ui.srcCbLanguageList->model()->sort(0, Qt::AscendingOrder); m_ui.srcCbLanguageList->insertItem(0, QLatin1String("POSIX"), QVariant(QLocale::C)); - for (int i = QLocale::AnyCountry + 1; i < QLocale::LastCountry; ++i) { - QString country = QLocale::countryToString(QLocale::Country(i)); - m_ui.srcCbCountryList->addItem(country, QVariant(i)); - } - m_ui.srcCbCountryList->model()->sort(0, Qt::AscendingOrder); - m_ui.srcCbCountryList->insertItem(0, tr("Any Country"), QVariant(QLocale::AnyCountry)); - m_ui.tgtCbLanguageList->setModel(m_ui.srcCbLanguageList->model()); - m_ui.tgtCbCountryList->setModel(m_ui.srcCbCountryList->model()); } void TranslationSettingsDialog::setDataModel(DataModel *dataModel) @@ -87,6 +79,31 @@ void TranslationSettingsDialog::setPhraseBook(PhraseBook *phraseBook) setWindowTitle(tr("Settings for '%1' - Qt Linguist").arg(fn)); } +static void fillCountryCombo(const QVariant &lng, QComboBox *combo) +{ + combo->clear(); + QLocale::Language lang = QLocale::Language(lng.toInt()); + if (lang != QLocale::C) { + foreach (QLocale::Country cntr, QLocale::countriesForLanguage(lang)) { + QString country = QLocale::countryToString(cntr); + combo->addItem(country, QVariant(cntr)); + } + combo->model()->sort(0, Qt::AscendingOrder); + } + combo->insertItem(0, TranslationSettingsDialog::tr("Any Country"), QVariant(QLocale::AnyCountry)); + combo->setCurrentIndex(0); +} + +void TranslationSettingsDialog::on_srcCbLanguageList_currentIndexChanged(int idx) +{ + fillCountryCombo(m_ui.srcCbLanguageList->itemData(idx), m_ui.srcCbCountryList); +} + +void TranslationSettingsDialog::on_tgtCbLanguageList_currentIndexChanged(int idx) +{ + fillCountryCombo(m_ui.tgtCbLanguageList->itemData(idx), m_ui.tgtCbCountryList); +} + void TranslationSettingsDialog::on_buttonBox_accepted() { int itemindex = m_ui.tgtCbLanguageList->currentIndex(); diff --git a/tools/linguist/linguist/translationsettingsdialog.h b/tools/linguist/linguist/translationsettingsdialog.h index 2408add..7908cd7 100644 --- a/tools/linguist/linguist/translationsettingsdialog.h +++ b/tools/linguist/linguist/translationsettingsdialog.h @@ -66,6 +66,8 @@ private: private slots: void on_buttonBox_accepted(); + void on_srcCbLanguageList_currentIndexChanged(int idx); + void on_tgtCbLanguageList_currentIndexChanged(int idx); private: Ui::TranslationSettingsDialog m_ui; -- cgit v0.12 From a0b17797b0d3ae5716d83eea36ea1adf51406730 Mon Sep 17 00:00:00 2001 From: Rhys Weatherley Date: Thu, 26 Nov 2009 15:49:47 +1000 Subject: Don't ask for pbuffers when searching for an OpenVG configuration Reviewed-by: Sarah Smith --- src/openvg/qwindowsurface_vgegl.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/openvg/qwindowsurface_vgegl.cpp b/src/openvg/qwindowsurface_vgegl.cpp index 29d82c8..e7d8113 100644 --- a/src/openvg/qwindowsurface_vgegl.cpp +++ b/src/openvg/qwindowsurface_vgegl.cpp @@ -211,19 +211,19 @@ static QEglContext *createContext(QPaintDevice *device) configProps.setValue(EGL_ALPHA_MASK_SIZE, 1); #endif #ifdef EGL_VG_ALPHA_FORMAT_PRE_BIT - configProps.setValue(EGL_SURFACE_TYPE, EGL_WINDOW_BIT | EGL_PBUFFER_BIT | + configProps.setValue(EGL_SURFACE_TYPE, EGL_WINDOW_BIT | EGL_VG_ALPHA_FORMAT_PRE_BIT); configProps.setRenderableType(QEgl::OpenVG); if (!context->chooseConfig(configProps)) { // Try again without the "pre" bit. - configProps.setValue(EGL_SURFACE_TYPE, EGL_WINDOW_BIT | EGL_PBUFFER_BIT); + configProps.setValue(EGL_SURFACE_TYPE, EGL_WINDOW_BIT); if (!context->chooseConfig(configProps)) { delete context; return 0; } } #else - configProps.setValue(EGL_SURFACE_TYPE, EGL_WINDOW_BIT | EGL_PBUFFER_BIT); + configProps.setValue(EGL_SURFACE_TYPE, EGL_WINDOW_BIT); configProps.setRenderableType(QEgl::OpenVG); if (!context->chooseConfig(configProps)) { delete context; -- cgit v0.12 From 88c9a52646ef1c695ef0a7461ed1f6a7ce923375 Mon Sep 17 00:00:00 2001 From: Rhys Weatherley Date: Thu, 26 Nov 2009 16:24:32 +1000 Subject: QT_VG_EGL_CONFIG env var to specify explicit EGL configs for OpenVG Reviewed-by: Sarah Smith --- src/openvg/qwindowsurface_vgegl.cpp | 36 ++++++++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) diff --git a/src/openvg/qwindowsurface_vgegl.cpp b/src/openvg/qwindowsurface_vgegl.cpp index e7d8113..62871cf 100644 --- a/src/openvg/qwindowsurface_vgegl.cpp +++ b/src/openvg/qwindowsurface_vgegl.cpp @@ -200,6 +200,42 @@ static QEglContext *createContext(QPaintDevice *device) else eglSwapInterval(context->display(), 1); +#ifdef EGL_RENDERABLE_TYPE + // Has the user specified an explicit EGL configuration to use? + QByteArray configId = qgetenv("QT_VG_EGL_CONFIG"); + if (!configId.isEmpty()) { + EGLint cfgId = configId.toInt(); + EGLint properties[] = { + EGL_CONFIG_ID, cfgId, + EGL_NONE + }; + EGLint matching = 0; + EGLConfig cfg; + if (eglChooseConfig + (context->display(), properties, &cfg, 1, &matching) && + matching > 0) { + // Check that the selected configuration actually supports OpenVG + // and then create the context with it. + EGLint id = 0; + EGLint type = 0; + eglGetConfigAttrib + (context->display(), cfg, EGL_CONFIG_ID, &id); + eglGetConfigAttrib + (context->display(), cfg, EGL_RENDERABLE_TYPE, &type); + if (cfgId == id && (type & EGL_OPENVG_BIT) != 0) { + context->setConfig(cfg); + if (!context->createContext()) { + delete context; + return 0; + } + return context; + } else { + qWarning("QT_VG_EGL_CONFIG: %d is not a valid OpenVG configuration", int(cfgId)); + } + } + } +#endif + // Choose an appropriate configuration for rendering into the device. QEglProperties configProps; configProps.setPaintDeviceFormat(device); -- cgit v0.12 From 0f06d08a3c5eb4d0397406ed559cfaba6e137492 Mon Sep 17 00:00:00 2001 From: Olivier Goffart Date: Wed, 25 Nov 2009 21:38:39 +0100 Subject: Optimize QObjectPrivate::isSignalConnected It can be seen in the GraphicsView benchmark. This function has to be as fast as possible. Make the function inline. We do not need 64bit for the connectedSignals bit array because it is very unlikely that an object will have more than 32 signals. (In Qt 4.5 it could have hapenned as the slot were counting in the index) Reviewed-by: bnilsen Reviewed-by: Brad --- src/corelib/kernel/qobject.cpp | 47 +++------------- src/corelib/kernel/qobject_p.h | 21 ++++++- tests/auto/qobject/tst_qobject.cpp | 109 +++++++++++++++++++++++++++++++++++++ 3 files changed, 135 insertions(+), 42 deletions(-) diff --git a/src/corelib/kernel/qobject.cpp b/src/corelib/kernel/qobject.cpp index 95602d9..4321c59 100644 --- a/src/corelib/kernel/qobject.cpp +++ b/src/corelib/kernel/qobject.cpp @@ -145,8 +145,7 @@ QObjectPrivate::QObjectPrivate(int version) receiveChildEvents = true; postedEvents = 0; extraData = 0; - for (uint i = 0; i < (sizeof connectedSignals / sizeof connectedSignals[0]); ++i) - connectedSignals[i] = 0; + connectedSignals = 0; inEventHandler = false; inThreadChangeEvent = false; deleteWatch = 0; @@ -2937,13 +2936,9 @@ bool QMetaObjectPrivate::connect(const QObject *sender, int signal_index, QObjectPrivate *const sender_d = QObjectPrivate::get(s); if (signal_index < 0) { - for (uint i = 0; i < (sizeof sender_d->connectedSignals - / sizeof sender_d->connectedSignals[0] ); ++i) - sender_d->connectedSignals[i] = ~0u; - } else if (signal_index < (int)sizeof sender_d->connectedSignals * 8) { - uint n = (signal_index / (8 * sizeof sender_d->connectedSignals[0])); - sender_d->connectedSignals[n] |= (1 << (signal_index - n * 8 - * sizeof sender_d->connectedSignals[0])); + sender_d->connectedSignals = ~ulong(0); + } else if (signal_index < (int)sizeof(sender_d->connectedSignals) * 8) { + sender_d->connectedSignals |= ulong(1) << signal_index; } return true; @@ -3201,15 +3196,9 @@ void QMetaObject::activate(QObject *sender, const QMetaObject *m, int local_sign computeOffsets(m, &signalOffset, &methodOffset); int signal_index = signalOffset + local_signal_index; - if (signal_index < (int)sizeof(sender->d_func()->connectedSignals) * 8 - && !qt_signal_spy_callback_set.signal_begin_callback - && !qt_signal_spy_callback_set.signal_end_callback) { - uint n = (signal_index / (8 * sizeof sender->d_func()->connectedSignals[0])); - uint m = 1 << (signal_index - n * 8 * sizeof sender->d_func()->connectedSignals[0]); - if ((sender->d_func()->connectedSignals[n] & m) == 0) - // nothing connected to these signals, and no spy - return; - } + + if (!sender->d_func()->isSignalConnected(signal_index)) + return; // nothing connected to these signals, and no spy if (sender->d_func()->blockSig) return; @@ -3370,28 +3359,6 @@ int QObjectPrivate::signalIndex(const char *signalName) const return relative_index + signalOffset; } -/*! \internal - - Returns true if the signal with index \a signal_index from object \a sender is connected. - Signals with indices above a certain range are always considered connected (see connectedSignals - in QObjectPrivate). If a signal spy is installed, all signals are considered connected. - - \a signal_index must be the index returned by QObjectPrivate::signalIndex; -*/ -bool QObjectPrivate::isSignalConnected(int signal_index) const -{ - if (signal_index < (int)sizeof(connectedSignals) * 8 - && !qt_signal_spy_callback_set.signal_begin_callback - && !qt_signal_spy_callback_set.signal_end_callback) { - uint n = (signal_index / (8 * sizeof connectedSignals[0])); - uint m = 1 << (signal_index - n * 8 * sizeof connectedSignals[0]); - if ((connectedSignals[n] & m) == 0) - // nothing connected to these signals, and no spy - return false; - } - return true; -} - /***************************************************************************** Properties *****************************************************************************/ diff --git a/src/corelib/kernel/qobject_p.h b/src/corelib/kernel/qobject_p.h index f087407..f899c78 100644 --- a/src/corelib/kernel/qobject_p.h +++ b/src/corelib/kernel/qobject_p.h @@ -172,7 +172,7 @@ public: } int signalIndex(const char *signalName) const; - bool isSignalConnected(int signalIdx) const; + inline bool isSignalConnected(int signalIdx) const; public: QString objectName; @@ -183,7 +183,7 @@ public: Connection *senders; // linked list of connections connected to this object Sender *currentSender; // object currently activating the object - mutable quint32 connectedSignals[2]; // 64-bit, so doesn't cause padding on 64-bit platforms + mutable ulong connectedSignals; #ifdef QT3_SUPPORT QList pendingChildInsertedEvents; @@ -205,6 +205,23 @@ public: int *deleteWatch; }; +/*! \internal + + Returns true if the signal with index \a signal_index from object \a sender is connected. + Signals with indices above a certain range are always considered connected (see connectedSignals + in QObjectPrivate). If a signal spy is installed, all signals are considered connected. + + \a signal_index must be the index returned by QObjectPrivate::signalIndex; +*/ +inline bool QObjectPrivate::isSignalConnected(int signal_index) const +{ + return signal_index >= (int)sizeof(connectedSignals) * 8 + || qt_signal_spy_callback_set.signal_begin_callback + || qt_signal_spy_callback_set.signal_end_callback + || (connectedSignals & (ulong(1) << signal_index)); +} + + inline void q_guard_addGuard(QGuard *g) { QObjectPrivate *p = QObjectPrivate::get(g->o); diff --git a/tests/auto/qobject/tst_qobject.cpp b/tests/auto/qobject/tst_qobject.cpp index 5035139..67a9c46 100644 --- a/tests/auto/qobject/tst_qobject.cpp +++ b/tests/auto/qobject/tst_qobject.cpp @@ -60,6 +60,10 @@ #include #include "qobject.h" +#ifdef QT_BUILD_INTERNAL +#include +#endif + #include @@ -121,6 +125,7 @@ private slots: void interfaceIid(); void deleteQObjectWhenDeletingEvent(); void overloads(); + void isSignalConnected(); protected: }; @@ -3016,5 +3021,109 @@ void tst_QObject::overloads() QCOMPARE(obj2.o4_obj, qApp); //default arg of the slot } +class ManySignals : public QObject +{ Q_OBJECT + friend class tst_QObject; +signals: + void sig00(); void sig01(); void sig02(); void sig03(); void sig04(); + void sig05(); void sig06(); void sig07(); void sig08(); void sig09(); + void sig10(); void sig11(); void sig12(); void sig13(); void sig14(); + void sig15(); void sig16(); void sig17(); void sig18(); void sig19(); + void sig20(); void sig21(); void sig22(); void sig23(); void sig24(); + void sig25(); void sig26(); void sig27(); void sig28(); void sig29(); + void sig30(); void sig31(); void sig32(); void sig33(); void sig34(); + void sig35(); void sig36(); void sig37(); void sig38(); void sig39(); + void sig40(); void sig41(); void sig42(); void sig43(); void sig44(); + void sig45(); void sig46(); void sig47(); void sig48(); void sig49(); + void sig50(); void sig51(); void sig52(); void sig53(); void sig54(); + void sig55(); void sig56(); void sig57(); void sig58(); void sig59(); + void sig60(); void sig61(); void sig62(); void sig63(); void sig64(); + void sig65(); void sig66(); void sig67(); void sig68(); void sig69(); + +public slots: + void received() { rec++; } +public: + int rec; +}; + + +void tst_QObject::isSignalConnected() +{ + ManySignals o; + o.rec = 0; +#ifdef QT_BUILD_INTERNAL + QObjectPrivate *priv = QObjectPrivate::get(&o); + QVERIFY(!priv->isSignalConnected(priv->signalIndex("destroyed()"))); + QVERIFY(!priv->isSignalConnected(priv->signalIndex("sig00()"))); + QVERIFY(!priv->isSignalConnected(priv->signalIndex("sig05()"))); + QVERIFY(!priv->isSignalConnected(priv->signalIndex("sig15()"))); + QVERIFY(!priv->isSignalConnected(priv->signalIndex("sig29()"))); + if (sizeof(void *) >= 8) { //on 32bit isSignalConnected only works with the first 32 signals + QVERIFY(!priv->isSignalConnected(priv->signalIndex("sig60()"))); + QVERIFY(!priv->isSignalConnected(priv->signalIndex("sig61()"))); + } +#endif + + QObject::connect(&o, SIGNAL(sig00()), &o, SIGNAL(sig69())); + QObject::connect(&o, SIGNAL(sig34()), &o, SIGNAL(sig03())); + QObject::connect(&o, SIGNAL(sig69()), &o, SIGNAL(sig34())); + QObject::connect(&o, SIGNAL(sig03()), &o, SIGNAL(sig18())); + +#ifdef QT_BUILD_INTERNAL + QVERIFY(!priv->isSignalConnected(priv->signalIndex("destroyed()"))); + QVERIFY(!priv->isSignalConnected(priv->signalIndex("sig05()"))); + QVERIFY(!priv->isSignalConnected(priv->signalIndex("sig15()"))); + QVERIFY(!priv->isSignalConnected(priv->signalIndex("sig29()"))); + + QVERIFY(priv->isSignalConnected(priv->signalIndex("sig00()"))); + QVERIFY(priv->isSignalConnected(priv->signalIndex("sig03()"))); + QVERIFY(priv->isSignalConnected(priv->signalIndex("sig34()"))); + QVERIFY(priv->isSignalConnected(priv->signalIndex("sig69()"))); + QVERIFY(!priv->isSignalConnected(priv->signalIndex("sig18()"))); +#endif + + QObject::connect(&o, SIGNAL(sig18()), &o, SIGNAL(sig29())); + QObject::connect(&o, SIGNAL(sig29()), &o, SIGNAL(sig62())); + QObject::connect(&o, SIGNAL(sig62()), &o, SIGNAL(sig28())); + QObject::connect(&o, SIGNAL(sig28()), &o, SIGNAL(sig27())); + +#ifdef QT_BUILD_INTERNAL + QVERIFY(priv->isSignalConnected(priv->signalIndex("sig18()"))); + QVERIFY(priv->isSignalConnected(priv->signalIndex("sig62()"))); + QVERIFY(priv->isSignalConnected(priv->signalIndex("sig28()"))); + QVERIFY(priv->isSignalConnected(priv->signalIndex("sig69()"))); + QVERIFY(!priv->isSignalConnected(priv->signalIndex("sig27()"))); +#endif + + QCOMPARE(o.rec, 0); + emit o.sig01(); + emit o.sig34(); + QCOMPARE(o.rec, 0); + + QObject::connect(&o, SIGNAL(sig27()), &o, SLOT(received())); + +#ifdef QT_BUILD_INTERNAL + QVERIFY(priv->isSignalConnected(priv->signalIndex("sig00()"))); + QVERIFY(priv->isSignalConnected(priv->signalIndex("sig03()"))); + QVERIFY(priv->isSignalConnected(priv->signalIndex("sig34()"))); + QVERIFY(priv->isSignalConnected(priv->signalIndex("sig18()"))); + QVERIFY(priv->isSignalConnected(priv->signalIndex("sig62()"))); + QVERIFY(priv->isSignalConnected(priv->signalIndex("sig28()"))); + QVERIFY(priv->isSignalConnected(priv->signalIndex("sig69()"))); + QVERIFY(priv->isSignalConnected(priv->signalIndex("sig27()"))); + + QVERIFY(!priv->isSignalConnected(priv->signalIndex("sig04()"))); + QVERIFY(!priv->isSignalConnected(priv->signalIndex("sig21()"))); + QVERIFY(!priv->isSignalConnected(priv->signalIndex("sig25()"))); +#endif + + emit o.sig00(); + QCOMPARE(o.rec, 1); + emit o.sig69(); + QCOMPARE(o.rec, 2); + emit o.sig36(); + QCOMPARE(o.rec, 2); +} + QTEST_MAIN(tst_QObject) #include "tst_qobject.moc" -- cgit v0.12 From c8494e085cd5abc3b30229409c7dacac676c81b9 Mon Sep 17 00:00:00 2001 From: Olivier Goffart Date: Thu, 26 Nov 2009 10:26:27 +0100 Subject: QGraphicsTextItem::setDefaultTextColor check change before calling update() Some applications call setDefaultTextColor in the paint event. Task-number: QTBUG-6242 Reviewed-by: Gabriel --- src/gui/graphicsview/qgraphicsitem.cpp | 4 +++- tests/auto/qgraphicsitem/tst_qgraphicsitem.cpp | 17 +++++++++++------ 2 files changed, 14 insertions(+), 7 deletions(-) diff --git a/src/gui/graphicsview/qgraphicsitem.cpp b/src/gui/graphicsview/qgraphicsitem.cpp index 34f42fb..1f87cd9 100644 --- a/src/gui/graphicsview/qgraphicsitem.cpp +++ b/src/gui/graphicsview/qgraphicsitem.cpp @@ -9441,9 +9441,11 @@ void QGraphicsTextItem::setDefaultTextColor(const QColor &col) { QTextControl *c = dd->textControl(); QPalette pal = c->palette(); + QColor old = pal.color(QPalette::Text); pal.setColor(QPalette::Text, col); c->setPalette(pal); - update(); + if (old != col) + update(); } /*! diff --git a/tests/auto/qgraphicsitem/tst_qgraphicsitem.cpp b/tests/auto/qgraphicsitem/tst_qgraphicsitem.cpp index db80db6..565a3e7 100644 --- a/tests/auto/qgraphicsitem/tst_qgraphicsitem.cpp +++ b/tests/auto/qgraphicsitem/tst_qgraphicsitem.cpp @@ -9759,16 +9759,16 @@ void tst_QGraphicsItem::QTBUG_5418_textItemSetDefaultColor() { struct Item : public QGraphicsTextItem { - bool painted; + int painted; void paint(QPainter *painter, const QStyleOptionGraphicsItem *opt, QWidget *wid) { - painted = true; + painted++; QGraphicsTextItem::paint(painter, opt, wid); } }; Item *i = new Item; - i->painted = false; + i->painted = 0; i->setPlainText("I AM A TROLL"); QGraphicsScene scene; @@ -9780,11 +9780,11 @@ void tst_QGraphicsItem::QTBUG_5418_textItemSetDefaultColor() QTRY_VERIFY(i->painted); QApplication::processEvents(); - i->painted = false; + i->painted = 0; QColor col(Qt::red); i->setDefaultTextColor(col); QApplication::processEvents(); - QTRY_VERIFY(i->painted); //check that changing the color force an update + QTRY_COMPARE(i->painted, 1); //check that changing the color force an update i->painted = false; QImage image(400, 200, QImage::Format_RGB32); @@ -9792,7 +9792,7 @@ void tst_QGraphicsItem::QTBUG_5418_textItemSetDefaultColor() QPainter painter(&image); scene.render(&painter); painter.end(); - QVERIFY(i->painted); + QCOMPARE(i->painted, 1); int numRedPixel = 0; QRgb rgb = col.rgb(); @@ -9810,6 +9810,11 @@ void tst_QGraphicsItem::QTBUG_5418_textItemSetDefaultColor() } } QCOMPARE(numRedPixel, -1); //color not found, FAIL! + + i->painted = 0; + i->setDefaultTextColor(col); + QApplication::processEvents(); + QCOMPARE(i->painted, 0); //same color as before should not trigger an update (QTBUG-6242) } QTEST_MAIN(tst_QGraphicsItem) -- cgit v0.12 From 8a6a554626b2362ef6a12faeb725a465eb33a9fa Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sami=20Meril=C3=A4?= Date: Thu, 26 Nov 2009 13:12:28 +0200 Subject: Remove some white-space from QS60Style Remove some white space from QS60Style classes. Reviewed-by: TrustMe --- src/gui/styles/qs60style.cpp | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/gui/styles/qs60style.cpp b/src/gui/styles/qs60style.cpp index 6c328b9..b71ec5d 100644 --- a/src/gui/styles/qs60style.cpp +++ b/src/gui/styles/qs60style.cpp @@ -643,7 +643,7 @@ void QS60StylePrivate::setThemePalette(QWidget *widget) const s60Color(QS60StyleEnums::CL_QsnTextColors, 23, 0)); QHeaderView* header = qobject_cast(widget); widgetPalette.setColor(QPalette::Button, Qt::transparent ); - if ( header->viewport() ) + if (header->viewport()) header->viewport()->setPalette(widgetPalette); QApplication::setPalette(widgetPalette, "QHeaderView"); } @@ -864,7 +864,7 @@ QSize QS60StylePrivate::partSize(QS60StyleEnums::SkinParts part, SkinElementFlag return result; } -bool QS60StylePrivate::canDrawThemeBackground(const QBrush &backgroundBrush) +bool QS60StylePrivate::canDrawThemeBackground(const QBrush &backgroundBrush) { //If brush is not changed from style's default values, draw theme graphics. return (backgroundBrush.color() == Qt::transparent || @@ -1782,7 +1782,7 @@ void QS60Style::drawControl(ControlElement element, const QStyleOption *option, if (qobject_cast(widget)) { //Make cornerButton slightly smaller so that it is not on top of table border graphic. QStyleOptionHeader subopt = *header; - const int borderTweak = + const int borderTweak = QS60StylePrivate::pixelMetric(PM_Custom_FrameCornerWidth)>>1; if (subopt.direction == Qt::LeftToRight) subopt.rect.adjust(borderTweak, borderTweak, 0, -borderTweak); @@ -1875,7 +1875,7 @@ void QS60Style::drawControl(ControlElement element, const QStyleOption *option, adjustableFlags = (adjustableFlags | QS60StylePrivate::SF_PointWest); } else { const int frameWidth = QS60StylePrivate::pixelMetric(PM_DefaultFrameWidth); - if (option->direction == Qt::LeftToRight) + if (option->direction == Qt::LeftToRight) headerRect.adjust(-2*frameWidth, 0, 0, 0); else headerRect.adjust(0, 0, 2*frameWidth, 0); @@ -2590,7 +2590,7 @@ QRect QS60Style::subControlRect(ComplexControl control, const QStyleOptionComple const int indicatorRect = pixelMetric(PM_MenuButtonIndicator) + 2*pixelMetric(PM_ButtonMargin); const int border = pixelMetric(PM_ButtonMargin) + pixelMetric(PM_DefaultFrameWidth); ret = toolButton->rect; - const bool popup = (toolButton->features & + const bool popup = (toolButton->features & (QStyleOptionToolButton::MenuButtonPopup | QStyleOptionToolButton::PopupDelay)) == QStyleOptionToolButton::MenuButtonPopup; switch (scontrol) { -- cgit v0.12 From 92c2102f5b1f3ab5ee1ac7a56aaabcd656804d04 Mon Sep 17 00:00:00 2001 From: Miikka Heikkinen Date: Thu, 26 Nov 2009 13:15:00 +0200 Subject: Made layout of the Softkeys example more compact Softkeys example didn't fit on the screen in landscape mode due to the widget minimum size enforcement done by Qt. Changed the layout of the example from QVBoxLayout to QGridlayout to make better use of the available space. Also shortened button texts. Task-number: QTBUG-6126 Reviewed-by: Janne Anttila --- examples/widgets/softkeys/softkeys.cpp | 16 ++++++++-------- examples/widgets/softkeys/softkeys.h | 2 +- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/examples/widgets/softkeys/softkeys.cpp b/examples/widgets/softkeys/softkeys.cpp index 69b4941..d1586a5 100644 --- a/examples/widgets/softkeys/softkeys.cpp +++ b/examples/widgets/softkeys/softkeys.cpp @@ -66,11 +66,11 @@ MainWindow::MainWindow(QWidget *parent) infoLabel = new QLabel(tr(""), this); infoLabel->setContextMenuPolicy(Qt::NoContextMenu); - toggleButton = new QPushButton(tr("Custom softkeys"), this); + toggleButton = new QPushButton(tr("Custom"), this); toggleButton->setContextMenuPolicy(Qt::NoContextMenu); toggleButton->setCheckable(true); - pushButton = new QPushButton(tr("Open File Dialog"), this); + pushButton = new QPushButton(tr("File Dialog"), this); pushButton->setContextMenuPolicy(Qt::NoContextMenu); QComboBox* comboBox = new QComboBox(this); @@ -81,12 +81,12 @@ MainWindow::MainWindow(QWidget *parent) << QApplication::translate("MainWindow", "Selection3", 0, QApplication::UnicodeUTF8) ); - layout = new QVBoxLayout; - layout->addWidget(textEditor); - layout->addWidget(infoLabel); - layout->addWidget(toggleButton); - layout->addWidget(pushButton); - layout->addWidget(comboBox); + layout = new QGridLayout; + layout->addWidget(textEditor, 0, 0, 1, 2); + layout->addWidget(infoLabel, 1, 0, 1, 2); + layout->addWidget(toggleButton, 2, 0); + layout->addWidget(pushButton, 2, 1); + layout->addWidget(comboBox, 3, 0, 1, 2); central->setLayout(layout); fileMenu = menuBar()->addMenu(tr("&File")); diff --git a/examples/widgets/softkeys/softkeys.h b/examples/widgets/softkeys/softkeys.h index 178ae64..1372fa4 100644 --- a/examples/widgets/softkeys/softkeys.h +++ b/examples/widgets/softkeys/softkeys.h @@ -61,7 +61,7 @@ public: MainWindow(QWidget *parent = 0); ~MainWindow(); private: - QVBoxLayout *layout; + QGridLayout *layout; QWidget *central; QTextEdit* textEditor; QLabel *infoLabel; -- cgit v0.12 From a78e7a6e7a7d5725467d0538bf8e0ea50c2506cc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thorbj=C3=B8rn=20Lindeijer?= Date: Tue, 24 Nov 2009 11:38:57 +0100 Subject: Improved and optimized the WaveUnderline The WaveUnderline used to be a series of 180 degree arcs, that didn't always align very well between different text items and that could be clipped at the bottom since the font height got reduced. Now it uses quad beziers so that it is more like a sinus curve, and the alignment and clipping issues have been fixed. The painting of the WaveUnderline has been optimized using QPixmapCache. A 100 pixels wide sample of the wave is now cached as a pixmap and repeated to draw the WaveUnderline. This is an order of magnitude faster than rasterizing a QPainterPath. The QPlainTextEdit needs to set the brush origin since it draws the text items in local widget coordinates, rather than relying on a painter translation like the QTextEdit. Done with mae. --- src/gui/painting/qpainter.cpp | 92 +++++++++++++++++++++++++------------- src/gui/widgets/qplaintextedit.cpp | 3 ++ 2 files changed, 63 insertions(+), 32 deletions(-) diff --git a/src/gui/painting/qpainter.cpp b/src/gui/painting/qpainter.cpp index 48629d1..fc1863f 100644 --- a/src/gui/painting/qpainter.cpp +++ b/src/gui/painting/qpainter.cpp @@ -5886,7 +5886,12 @@ void QPainter::drawText(const QRectF &r, const QString &text, const QTextOption Draws the text item \a ti at position \a p. */ -/*! \internal +/*! + \fn void QPainter::drawTextItem(const QPointF &p, const QTextItem &ti) + + \internal + \since 4.1 + Draws the text item \a ti at position \a p. This method ignores the painters background mode and @@ -5899,34 +5904,57 @@ void QPainter::drawText(const QRectF &r, const QString &text, const QTextOption ignored aswell. You'll need to pass in the correct flags to get underlining and strikeout. */ -static QPainterPath generateWavyPath(qreal minWidth, qreal maxRadius, QPaintDevice *device) + +static QPixmap generateWavyPixmap(qreal maxRadius, const QPen &pen) { - extern int qt_defaultDpi(); + const qreal radiusBase = qMax(qreal(1), maxRadius); + + QString key = QLatin1String("WaveUnderline-"); + key += pen.color().name(); + key += QLatin1Char('-'); + key += QString::number(radiusBase); + + QPixmap pixmap; + if (QPixmapCache::find(key, pixmap)) + return pixmap; + + const qreal halfPeriod = qMax(qreal(2), radiusBase * 1.61803399); // the golden ratio + const int width = qCeil(100 / (2 * halfPeriod)) * (2 * halfPeriod); + const int radius = qFloor(radiusBase); + QPainterPath path; - bool up = true; - const qreal radius = qMax(qreal(.5), qMin(qreal(1.25 * device->logicalDpiY() / qt_defaultDpi()), maxRadius)); - qreal xs, ys; - int i = 0; - path.moveTo(0, radius); - do { - xs = i*(2*radius); - ys = 0; + qreal xs = 0; + qreal ys = radius; - qreal remaining = minWidth - xs; - qreal angle = 180; + while (xs < width) { + xs += halfPeriod; + ys = -ys; + path.quadTo(xs - halfPeriod / 2, ys, xs, 0); + } - // cut-off at the last arc segment - if (remaining < 2 * radius) - angle = 180 * remaining / (2 * radius); + pixmap = QPixmap(width, radius * 2); + pixmap.fill(Qt::transparent); + { + QPen wavePen = pen; + wavePen.setCapStyle(Qt::SquareCap); + + // This is to protect against making the line too fat, as happens on Mac OS X + // due to it having a rather thick width for the regular underline. + const qreal maxPenWidth = .8 * radius; + if (wavePen.widthF() > maxPenWidth) + wavePen.setWidth(maxPenWidth); - path.arcTo(xs, ys, 2*radius, 2*radius, 180, up ? angle : -angle); + QPainter imgPainter(&pixmap); + imgPainter.setPen(wavePen); + imgPainter.setRenderHint(QPainter::Antialiasing); + imgPainter.translate(0, radius); + imgPainter.drawPath(path); + } - up = !up; - ++i; - } while (xs + 2*radius < minWidth); + QPixmapCache::insert(key, pixmap); - return path; + return pixmap; } static void drawTextItemDecoration(QPainter *painter, const QPointF &pos, const QTextItemInt &ti) @@ -5947,9 +5975,11 @@ static void drawTextItemDecoration(QPainter *painter, const QPointF &pos, const pen.setCapStyle(Qt::FlatCap); QLineF line(pos.x(), pos.y(), pos.x() + ti.width.toReal(), pos.y()); + + const qreal underlineOffset = fe->underlinePosition().toReal(); // deliberately ceil the offset to avoid the underline coming too close to // the text above it. - const qreal underlinePos = pos.y() + qCeil(fe->underlinePosition().toReal()); + const qreal underlinePos = pos.y() + qCeil(underlineOffset); if (underlineStyle == QTextCharFormat::SpellCheckUnderline) { underlineStyle = QTextCharFormat::UnderlineStyle(QApplication::style()->styleHint(QStyle::SH_SpellCheckUnderlineStyle)); @@ -5957,16 +5987,18 @@ static void drawTextItemDecoration(QPainter *painter, const QPointF &pos, const if (underlineStyle == QTextCharFormat::WaveUnderline) { painter->save(); - painter->setRenderHint(QPainter::Antialiasing); - painter->translate(pos.x(), underlinePos); + painter->translate(0, pos.y() + 1); QColor uc = ti.charFormat.underlineColor(); if (uc.isValid()) - painter->setPen(uc); + pen.setColor(uc); - painter->drawPath(generateWavyPath(ti.width.toReal(), - fe->underlinePosition().toReal(), - painter->device())); + // Adapt wave to underlineOffset or pen width, whatever is larger, to make it work on all platforms + const QPixmap wave = generateWavyPixmap(qMax(underlineOffset, pen.widthF()), pen); + const int descent = (int) ti.descent.toReal(); + + painter->setBrushOrigin(painter->brushOrigin().x(), 0); + painter->fillRect(pos.x(), 0, qCeil(ti.width.toReal()), qMin(wave.height(), descent), wave); painter->restore(); } else if (underlineStyle != QTextCharFormat::NoUnderline) { QLineF underLine(line.x1(), underlinePos, line.x2(), underlinePos); @@ -6001,10 +6033,6 @@ static void drawTextItemDecoration(QPainter *painter, const QPointF &pos, const painter->setBrush(oldBrush); } -/*! - \internal - \since 4.1 -*/ void QPainter::drawTextItem(const QPointF &p, const QTextItem &_ti) { #ifdef QT_DEBUG_DRAW diff --git a/src/gui/widgets/qplaintextedit.cpp b/src/gui/widgets/qplaintextedit.cpp index c7759e8..eae8b7d 100644 --- a/src/gui/widgets/qplaintextedit.cpp +++ b/src/gui/widgets/qplaintextedit.cpp @@ -1802,6 +1802,9 @@ void QPlainTextEdit::paintEvent(QPaintEvent *e) QTextBlock block = firstVisibleBlock(); qreal maximumWidth = document()->documentLayout()->documentSize().width(); + // Set a brush origin so that the WaveUnderline knows where the wave started + painter.setBrushOrigin(offset); + // keep right margin clean from full-width selection int maxX = offset.x() + qMax((qreal)viewportRect.width(), maximumWidth) - document()->documentMargin(); -- cgit v0.12 From df83eaa02d9c1b697438d237daab3fb7aac02ab7 Mon Sep 17 00:00:00 2001 From: Gordon Schumacher Date: Sat, 21 Nov 2009 11:19:54 -0700 Subject: Fix uninitialized error variable if the stream doesn't exist Merge-request: 2174 Reviewed-by: Eskil --- src/3rdparty/harfbuzz/src/harfbuzz-shaper.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/3rdparty/harfbuzz/src/harfbuzz-shaper.cpp b/src/3rdparty/harfbuzz/src/harfbuzz-shaper.cpp index f3ec8e1..bfb03ab 100644 --- a/src/3rdparty/harfbuzz/src/harfbuzz-shaper.cpp +++ b/src/3rdparty/harfbuzz/src/harfbuzz-shaper.cpp @@ -975,7 +975,7 @@ HB_Face HB_NewFace(void *font, HB_GetFontTableFunc tableFunc) face->glyphs_substituted = false; face->buffer = 0; - HB_Error error; + HB_Error error = HB_Err_Ok; HB_Stream stream; HB_Stream gdefStream; -- cgit v0.12 From c85d85b2a63cdbcf607789ed94ab5e4ac7ee560d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sami=20Meril=C3=A4?= Date: Thu, 26 Nov 2009 13:50:29 +0200 Subject: Background in landscape mode on S60 5.0 is broken After initial fix, 99% of widgets draw temselves properly after orientation switch. However, QScrollAreas lose their palette hash, which causes scrollarea background to re-start from theme background top-left. As a correction, we re-set the theme palette hash after calling QApplication::setPalette, since that clears palette hash. Task-number: QTBUG-6125 Reviewed-by: Alessandro Portale --- src/gui/styles/qs60style.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/src/gui/styles/qs60style.cpp b/src/gui/styles/qs60style.cpp index b71ec5d..a9636b6 100644 --- a/src/gui/styles/qs60style.cpp +++ b/src/gui/styles/qs60style.cpp @@ -471,6 +471,7 @@ void QS60StylePrivate::setBackgroundTexture(QApplication *app) const applicationPalette.setBrush(QPalette::Window, backgroundTexture()); setThemePalette(&applicationPalette); QApplication::setPalette(applicationPalette); + setThemePaletteHash(&applicationPalette); } void QS60StylePrivate::deleteBackground() -- cgit v0.12 From 0607d4e999da14a76d032103d9f459e95cb4ad89 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sami=20Meril=C3=A4?= Date: Thu, 26 Nov 2009 13:50:29 +0200 Subject: Background in landscape mode on S60 5.0 is broken After initial fix, 99% of widgets draw temselves properly after orientation switch. However, QScrollAreas lose their palette hash, which causes scrollarea background to re-start from theme background top-left. As a correction, we re-set the theme palette hash after calling QApplication::setPalette, since that clears palette hash. Task-number: QTBUG-6125 Reviewed-by: Alessandro Portale --- src/gui/styles/qs60style.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/src/gui/styles/qs60style.cpp b/src/gui/styles/qs60style.cpp index 2137244..ee10ff6 100644 --- a/src/gui/styles/qs60style.cpp +++ b/src/gui/styles/qs60style.cpp @@ -476,6 +476,7 @@ void QS60StylePrivate::setBackgroundTexture(QApplication *app) const applicationPalette.setBrush(QPalette::Window, backgroundTexture()); setThemePalette(&applicationPalette); QApplication::setPalette(applicationPalette); + setThemePaletteHash(&applicationPalette); } void QS60StylePrivate::deleteBackground() -- cgit v0.12 From b56dcd0f2093c35b1d638eebe38d113e8d59ea0c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sami=20Meril=C3=A4?= Date: Thu, 26 Nov 2009 14:17:11 +0200 Subject: Tidyup QS60Style - remove unused constants, replace magic values Basically this has three minor fixes: - remove unused style parts that were left over after unifying textEdit and lineEdit graphics - make radiobutton indicator one pixel smaller so it is perfect circle - replace magic "10" with calculated value Reviewed-by: Alessandro Portale --- src/gui/styles/qs60style.cpp | 6 +++--- src/gui/styles/qs60style_p.h | 9 --------- 2 files changed, 3 insertions(+), 12 deletions(-) diff --git a/src/gui/styles/qs60style.cpp b/src/gui/styles/qs60style.cpp index a9636b6..dca78ca 100644 --- a/src/gui/styles/qs60style.cpp +++ b/src/gui/styles/qs60style.cpp @@ -144,7 +144,7 @@ const struct QS60StylePrivate::frameElementCenter QS60StylePrivate::m_frameEleme {SE_ToolBarButtonPressed, QS60StyleEnums::SP_QsnFrSctrlButtonCenterPressed}, {SE_PanelBackground, QS60StyleEnums::SP_QsnFrSetOptCenter}, {SE_ButtonInactive, QS60StyleEnums::SP_QsnFrButtonCenterInactive}, - {SE_Editor, QS60StyleEnums::SP_QsnFrNotepadCenter}, + {SE_Editor, QS60StyleEnums::SP_QsnFrInputCenter}, }; static const int frameElementsCount = @@ -807,7 +807,7 @@ QSize QS60StylePrivate::partSize(QS60StyleEnums::SkinParts part, SkinElementFlag case QS60StyleEnums::SP_QgnGrafTabActiveL: //Returned QSize for tabs must not be square, but narrow rectangle with width:height //ratio of 1:2 for horizontal tab bars (and 2:1 for vertical ones). - result.setWidth(10); + result.setWidth(result.height()>>1); break; case QS60StyleEnums::SP_QgnIndiSliderEdit: result.scale(pixelMetric(QStyle::PM_SliderLength), @@ -2022,7 +2022,7 @@ void QS60Style::drawPrimitive(PrimitiveElement element, const QStyleOption *opti buttonRect.setHeight((int)(buttonRect.height() * scaler)); // move the rect up for half of the new height-gain const int newY = (buttonRect.bottomRight().y() - option->rect.bottomRight().y()) >> 1 ; - buttonRect.adjust(0,-newY,0,-newY); + buttonRect.adjust(0, -newY, -1, -newY); painter->save(); QColor themeColor = d->s60Color(QS60StyleEnums::CL_QsnTextColors, 6, option); diff --git a/src/gui/styles/qs60style_p.h b/src/gui/styles/qs60style_p.h index 36979a2..5ab2308 100644 --- a/src/gui/styles/qs60style_p.h +++ b/src/gui/styles/qs60style_p.h @@ -271,15 +271,6 @@ public: SP_QsnFrButtonSideLInactive, SP_QsnFrButtonSideRInactive, SP_QsnFrButtonCenterInactive, - SP_QsnFrNotepadCornerTl, - SP_QsnFrNotepadCornerTr, - SP_QsnFrNotepadCornerBl, - SP_QsnFrNotepadCornerBr, - SP_QsnFrNotepadSideT, - SP_QsnFrNotepadSideB, - SP_QsnFrNotepadSideL, - SP_QsnFrNotepadSideR, - SP_QsnFrNotepadCenter }; enum ColorLists { -- cgit v0.12 From 72d555e13e5c337bb298195441eec512bb070b7c Mon Sep 17 00:00:00 2001 From: Kim Motoyoshi Kalland Date: Thu, 26 Nov 2009 12:27:51 +0100 Subject: Fixed miter joins generated by the GL2 engine stroker. The stroker generated two points for each miter join, one on the convex side of the join, and one on the concave side. For sharp joins between curved segments, the point on the concave side could end up poking out of the stroke. This was fixed by generating one point on the convex side only. Reviewed-by: Trond --- .../gl2paintengineex/qtriangulatingstroker_p.h | 53 +++++++++++++++------- 1 file changed, 36 insertions(+), 17 deletions(-) diff --git a/src/opengl/gl2paintengineex/qtriangulatingstroker_p.h b/src/opengl/gl2paintengineex/qtriangulatingstroker_p.h index 412e239..fd2972c 100644 --- a/src/opengl/gl2paintengineex/qtriangulatingstroker_p.h +++ b/src/opengl/gl2paintengineex/qtriangulatingstroker_p.h @@ -301,23 +301,42 @@ void QTriangulatingStroker::join(const qreal *pts) case Qt::BevelJoin: break; case Qt::MiterJoin: { - int p1 = m_vertices.size() - 6; - int p2 = m_vertices.size() - 2; - QLineF line(m_vertices.at(p1), m_vertices.at(p1+1), - m_vertices.at(p2), m_vertices.at(p2+1)); - QLineF nextLine(m_cx - m_nvx, m_cy - m_nvy, - pts[0] - m_nvx, pts[1] - m_nvy); - - QPointF isect; - if (line.intersect(nextLine, &isect) != QLineF::NoIntersection - && QLineF(line.p2(), isect).length() <= m_miter_limit) { - // The intersection point mirrored over the m_cx, m_cy point - m_vertices.add(m_cx - (isect.x() - m_cx)); - m_vertices.add(m_cy - (isect.y() - m_cy)); - - // The intersection point - m_vertices.add(isect.x()); - m_vertices.add(isect.y()); + // Find out on which side the join should be. + int count = m_vertices.size(); + float prevNvx = m_vertices.at(count - 2) - m_cx; + float prevNvy = m_vertices.at(count - 1) - m_cy; + float xprod = prevNvx * m_nvy - prevNvy * m_nvx; + float px, py, qx, qy; + + // If the segments are parallel, use bevel join. + if (qFuzzyIsNull(xprod)) + break; + + // Find the corners of the previous and next segment to join. + if (xprod < 0) { + px = m_vertices.at(count - 2); + py = m_vertices.at(count - 1); + qx = m_cx - m_nvx; + qy = m_cy - m_nvy; + } else { + px = m_vertices.at(count - 4); + py = m_vertices.at(count - 3); + qx = m_cx + m_nvx; + qy = m_cy + m_nvy; + } + + // Find intersection point. + float pu = px * prevNvx + py * prevNvy; + float qv = qx * m_nvx + qy * m_nvy; + float ix = (m_nvy * pu - prevNvy * qv) / xprod; + float iy = (prevNvx * qv - m_nvx * pu) / xprod; + + // Check that the distance to the intersection point is less than the miter limit. + if ((ix - px) * (ix - px) + (iy - py) * (iy - py) <= m_miter_limit * m_miter_limit) { + m_vertices.add(ix); + m_vertices.add(iy); + m_vertices.add(ix); + m_vertices.add(iy); } // else // Do a plain bevel join if the miter limit is exceeded or if -- cgit v0.12 From c77a556265847529bb1c55ce3c8ae21080161f38 Mon Sep 17 00:00:00 2001 From: Kim Motoyoshi Kalland Date: Thu, 26 Nov 2009 12:59:17 +0100 Subject: Moved functions from .h to .cpp in the GL2 engine stroker. Some of the functions had become too long to be inlined in my opinion. Reviewed-by: Trond --- .../gl2paintengineex/qtriangulatingstroker.cpp | 204 +++++++++++++++++++ .../gl2paintengineex/qtriangulatingstroker_p.h | 223 +-------------------- 2 files changed, 208 insertions(+), 219 deletions(-) diff --git a/src/opengl/gl2paintengineex/qtriangulatingstroker.cpp b/src/opengl/gl2paintengineex/qtriangulatingstroker.cpp index 1478b09..c78f73f 100644 --- a/src/opengl/gl2paintengineex/qtriangulatingstroker.cpp +++ b/src/opengl/gl2paintengineex/qtriangulatingstroker.cpp @@ -209,6 +209,65 @@ void QTriangulatingStroker::process(const QVectorPath &path, const QPen &pen) } } +void QTriangulatingStroker::moveTo(const qreal *pts) +{ + m_cx = pts[0]; + m_cy = pts[1]; + + float x2 = pts[2]; + float y2 = pts[3]; + normalVector(m_cx, m_cy, x2, y2, &m_nvx, &m_nvy); + + + // To acheive jumps we insert zero-area tringles. This is done by + // adding two identical points in both the end of previous strip + // and beginning of next strip + bool invisibleJump = m_vertices.size(); + + switch (m_cap_style) { + case Qt::FlatCap: + if (invisibleJump) { + m_vertices.add(m_cx + m_nvx); + m_vertices.add(m_cy + m_nvy); + } + break; + case Qt::SquareCap: { + float sx = m_cx - m_nvy; + float sy = m_cy + m_nvx; + if (invisibleJump) { + m_vertices.add(sx + m_nvx); + m_vertices.add(sy + m_nvy); + } + emitLineSegment(sx, sy, m_nvx, m_nvy); + break; } + case Qt::RoundCap: { + QVarLengthArray points; + arcPoints(m_cx, m_cy, m_cx + m_nvx, m_cy + m_nvy, m_cx - m_nvx, m_cy - m_nvy, points); + m_vertices.resize(m_vertices.size() + points.size() + 2 * int(invisibleJump)); + int count = m_vertices.size(); + int front = 0; + int end = points.size() / 2; + while (front != end) { + m_vertices.at(--count) = points[2 * end - 1]; + m_vertices.at(--count) = points[2 * end - 2]; + --end; + if (front == end) + break; + m_vertices.at(--count) = points[2 * front + 1]; + m_vertices.at(--count) = points[2 * front + 0]; + ++front; + } + + if (invisibleJump) { + m_vertices.at(count - 1) = m_vertices.at(count + 1); + m_vertices.at(count - 2) = m_vertices.at(count + 0); + } + break; } + default: break; // ssssh gcc... + } + emitLineSegment(m_cx, m_cy, m_nvx, m_nvy); +} + void QTriangulatingStroker::cubicTo(const qreal *pts) { const QPointF *p = (const QPointF *) pts; @@ -246,6 +305,151 @@ void QTriangulatingStroker::cubicTo(const qreal *pts) m_nvy = vy; } +void QTriangulatingStroker::join(const qreal *pts) +{ + // Creates a join to the next segment (m_cx, m_cy) -> (pts[0], pts[1]) + normalVector(m_cx, m_cy, pts[0], pts[1], &m_nvx, &m_nvy); + + switch (m_join_style) { + case Qt::BevelJoin: + break; + case Qt::MiterJoin: { + // Find out on which side the join should be. + int count = m_vertices.size(); + float prevNvx = m_vertices.at(count - 2) - m_cx; + float prevNvy = m_vertices.at(count - 1) - m_cy; + float xprod = prevNvx * m_nvy - prevNvy * m_nvx; + float px, py, qx, qy; + + // If the segments are parallel, use bevel join. + if (qFuzzyIsNull(xprod)) + break; + + // Find the corners of the previous and next segment to join. + if (xprod < 0) { + px = m_vertices.at(count - 2); + py = m_vertices.at(count - 1); + qx = m_cx - m_nvx; + qy = m_cy - m_nvy; + } else { + px = m_vertices.at(count - 4); + py = m_vertices.at(count - 3); + qx = m_cx + m_nvx; + qy = m_cy + m_nvy; + } + + // Find intersection point. + float pu = px * prevNvx + py * prevNvy; + float qv = qx * m_nvx + qy * m_nvy; + float ix = (m_nvy * pu - prevNvy * qv) / xprod; + float iy = (prevNvx * qv - m_nvx * pu) / xprod; + + // Check that the distance to the intersection point is less than the miter limit. + if ((ix - px) * (ix - px) + (iy - py) * (iy - py) <= m_miter_limit * m_miter_limit) { + m_vertices.add(ix); + m_vertices.add(iy); + m_vertices.add(ix); + m_vertices.add(iy); + } + // else + // Do a plain bevel join if the miter limit is exceeded or if + // the lines are parallel. This is not what the raster + // engine's stroker does, but it is both faster and similar to + // what some other graphics API's do. + + break; } + case Qt::RoundJoin: { + QVarLengthArray points; + int count = m_vertices.size(); + float prevNvx = m_vertices.at(count - 2) - m_cx; + float prevNvy = m_vertices.at(count - 1) - m_cy; + if (m_nvx * prevNvy - m_nvy * prevNvx < 0) { + arcPoints(0, 0, m_nvx, m_nvy, -prevNvx, -prevNvy, points); + for (int i = points.size() / 2; i > 0; --i) + emitLineSegment(m_cx, m_cy, points[2 * i - 2], points[2 * i - 1]); + } else { + arcPoints(0, 0, -prevNvx, -prevNvy, m_nvx, m_nvy, points); + for (int i = 0; i < points.size() / 2; ++i) + emitLineSegment(m_cx, m_cy, points[2 * i + 0], points[2 * i + 1]); + } + break; } + default: break; // gcc warn-- + } + + emitLineSegment(m_cx, m_cy, m_nvx, m_nvy); +} + +void QTriangulatingStroker::endCap(const qreal *) +{ + switch (m_cap_style) { + case Qt::FlatCap: + break; + case Qt::SquareCap: + emitLineSegment(m_cx + m_nvy, m_cy - m_nvx, m_nvx, m_nvy); + break; + case Qt::RoundCap: { + QVarLengthArray points; + int count = m_vertices.size(); + arcPoints(m_cx, m_cy, m_vertices.at(count - 2), m_vertices.at(count - 1), m_vertices.at(count - 4), m_vertices.at(count - 3), points); + int front = 0; + int end = points.size() / 2; + while (front != end) { + m_vertices.add(points[2 * end - 2]); + m_vertices.add(points[2 * end - 1]); + --end; + if (front == end) + break; + m_vertices.add(points[2 * front + 0]); + m_vertices.add(points[2 * front + 1]); + ++front; + } + break; } + default: break; // to shut gcc up... + } +} + +void QTriangulatingStroker::arcPoints(float cx, float cy, float fromX, float fromY, float toX, float toY, QVarLengthArray &points) +{ + float dx1 = fromX - cx; + float dy1 = fromY - cy; + float dx2 = toX - cx; + float dy2 = toY - cy; + + // while more than 180 degrees left: + while (dx1 * dy2 - dx2 * dy1 < 0) { + float tmpx = dx1 * m_cos_theta - dy1 * m_sin_theta; + float tmpy = dx1 * m_sin_theta + dy1 * m_cos_theta; + dx1 = tmpx; + dy1 = tmpy; + points.append(cx + dx1); + points.append(cy + dy1); + } + + // while more than 90 degrees left: + while (dx1 * dx2 + dy1 * dy2 < 0) { + float tmpx = dx1 * m_cos_theta - dy1 * m_sin_theta; + float tmpy = dx1 * m_sin_theta + dy1 * m_cos_theta; + dx1 = tmpx; + dy1 = tmpy; + points.append(cx + dx1); + points.append(cy + dy1); + } + + // while more than 0 degrees left: + while (dx1 * dy2 - dx2 * dy1 > 0) { + float tmpx = dx1 * m_cos_theta - dy1 * m_sin_theta; + float tmpy = dx1 * m_sin_theta + dy1 * m_cos_theta; + dx1 = tmpx; + dy1 = tmpy; + points.append(cx + dx1); + points.append(cy + dy1); + } + + // remove last point which was rotated beyond [toX, toY]. + if (!points.isEmpty()) + points.resize(points.size() - 2); +} + static void qdashprocessor_moveTo(qreal x, qreal y, void *data) { ((QDashedStrokeProcessor *) data)->addElement(QPainterPath::MoveToElement, x, y); diff --git a/src/opengl/gl2paintengineex/qtriangulatingstroker_p.h b/src/opengl/gl2paintengineex/qtriangulatingstroker_p.h index fd2972c..2dba0ce 100644 --- a/src/opengl/gl2paintengineex/qtriangulatingstroker_p.h +++ b/src/opengl/gl2paintengineex/qtriangulatingstroker_p.h @@ -63,13 +63,13 @@ public: private: inline void emitLineSegment(float x, float y, float nx, float ny); - inline void moveTo(const qreal *pts); + void moveTo(const qreal *pts); inline void lineTo(const qreal *pts); void cubicTo(const qreal *pts); - inline void join(const qreal *pts); + void join(const qreal *pts); inline void normalVector(float x1, float y1, float x2, float y2, float *nx, float *ny); - inline void endCap(const qreal *pts); - inline void arcPoints(float cx, float cy, float fromX, float fromY, float toX, float toY, QVarLengthArray &points); + void endCap(const qreal *pts); + void arcPoints(float cx, float cy, float fromX, float fromY, float toX, float toY, QVarLengthArray &points); void endCapOrJoinClosed(const qreal *start, const qreal *cur, bool implicitClose, bool endsAtStart); @@ -117,10 +117,6 @@ private: qreal m_inv_scale; }; - - - - inline void QTriangulatingStroker::normalVector(float x1, float y1, float x2, float y2, float *nx, float *ny) { @@ -140,8 +136,6 @@ inline void QTriangulatingStroker::normalVector(float x1, float y1, float x2, fl *ny = dx * pw; } - - inline void QTriangulatingStroker::emitLineSegment(float x, float y, float vx, float vy) { m_vertices.add(x + vx); @@ -150,139 +144,6 @@ inline void QTriangulatingStroker::emitLineSegment(float x, float y, float vx, f m_vertices.add(y - vy); } -inline void QTriangulatingStroker::arcPoints(float cx, float cy, float fromX, float fromY, float toX, float toY, QVarLengthArray &points) -{ - float dx1 = fromX - cx; - float dy1 = fromY - cy; - float dx2 = toX - cx; - float dy2 = toY - cy; - - // while more than 180 degrees left: - while (dx1 * dy2 - dx2 * dy1 < 0) { - float tmpx = dx1 * m_cos_theta - dy1 * m_sin_theta; - float tmpy = dx1 * m_sin_theta + dy1 * m_cos_theta; - dx1 = tmpx; - dy1 = tmpy; - points.append(cx + dx1); - points.append(cy + dy1); - } - - // while more than 90 degrees left: - while (dx1 * dx2 + dy1 * dy2 < 0) { - float tmpx = dx1 * m_cos_theta - dy1 * m_sin_theta; - float tmpy = dx1 * m_sin_theta + dy1 * m_cos_theta; - dx1 = tmpx; - dy1 = tmpy; - points.append(cx + dx1); - points.append(cy + dy1); - } - - // while more than 0 degrees left: - while (dx1 * dy2 - dx2 * dy1 > 0) { - float tmpx = dx1 * m_cos_theta - dy1 * m_sin_theta; - float tmpy = dx1 * m_sin_theta + dy1 * m_cos_theta; - dx1 = tmpx; - dy1 = tmpy; - points.append(cx + dx1); - points.append(cy + dy1); - } - - // remove last point which was rotated beyond [toX, toY]. - if (!points.isEmpty()) - points.resize(points.size() - 2); -} - -inline void QTriangulatingStroker::endCap(const qreal *) -{ - switch (m_cap_style) { - case Qt::FlatCap: - break; - case Qt::SquareCap: - emitLineSegment(m_cx + m_nvy, m_cy - m_nvx, m_nvx, m_nvy); - break; - case Qt::RoundCap: { - QVarLengthArray points; - int count = m_vertices.size(); - arcPoints(m_cx, m_cy, m_vertices.at(count - 2), m_vertices.at(count - 1), m_vertices.at(count - 4), m_vertices.at(count - 3), points); - int front = 0; - int end = points.size() / 2; - while (front != end) { - m_vertices.add(points[2 * end - 2]); - m_vertices.add(points[2 * end - 1]); - --end; - if (front == end) - break; - m_vertices.add(points[2 * front + 0]); - m_vertices.add(points[2 * front + 1]); - ++front; - } - break; } - default: break; // to shut gcc up... - } -} - - -void QTriangulatingStroker::moveTo(const qreal *pts) -{ - m_cx = pts[0]; - m_cy = pts[1]; - - float x2 = pts[2]; - float y2 = pts[3]; - normalVector(m_cx, m_cy, x2, y2, &m_nvx, &m_nvy); - - - // To acheive jumps we insert zero-area tringles. This is done by - // adding two identical points in both the end of previous strip - // and beginning of next strip - bool invisibleJump = m_vertices.size(); - - switch (m_cap_style) { - case Qt::FlatCap: - if (invisibleJump) { - m_vertices.add(m_cx + m_nvx); - m_vertices.add(m_cy + m_nvy); - } - break; - case Qt::SquareCap: { - float sx = m_cx - m_nvy; - float sy = m_cy + m_nvx; - if (invisibleJump) { - m_vertices.add(sx + m_nvx); - m_vertices.add(sy + m_nvy); - } - emitLineSegment(sx, sy, m_nvx, m_nvy); - break; } - case Qt::RoundCap: { - QVarLengthArray points; - arcPoints(m_cx, m_cy, m_cx + m_nvx, m_cy + m_nvy, m_cx - m_nvx, m_cy - m_nvy, points); - m_vertices.resize(m_vertices.size() + points.size() + 2 * int(invisibleJump)); - int count = m_vertices.size(); - int front = 0; - int end = points.size() / 2; - while (front != end) { - m_vertices.at(--count) = points[2 * end - 1]; - m_vertices.at(--count) = points[2 * end - 2]; - --end; - if (front == end) - break; - m_vertices.at(--count) = points[2 * front + 1]; - m_vertices.at(--count) = points[2 * front + 0]; - ++front; - } - - if (invisibleJump) { - m_vertices.at(count - 1) = m_vertices.at(count + 1); - m_vertices.at(count - 2) = m_vertices.at(count + 0); - } - break; } - default: break; // ssssh gcc... - } - emitLineSegment(m_cx, m_cy, m_nvx, m_nvy); -} - - - void QTriangulatingStroker::lineTo(const qreal *pts) { emitLineSegment(pts[0], pts[1], m_nvx, m_nvy); @@ -290,82 +151,6 @@ void QTriangulatingStroker::lineTo(const qreal *pts) m_cy = pts[1]; } - - -void QTriangulatingStroker::join(const qreal *pts) -{ - // Creates a join to the next segment (m_cx, m_cy) -> (pts[0], pts[1]) - normalVector(m_cx, m_cy, pts[0], pts[1], &m_nvx, &m_nvy); - - switch (m_join_style) { - case Qt::BevelJoin: - break; - case Qt::MiterJoin: { - // Find out on which side the join should be. - int count = m_vertices.size(); - float prevNvx = m_vertices.at(count - 2) - m_cx; - float prevNvy = m_vertices.at(count - 1) - m_cy; - float xprod = prevNvx * m_nvy - prevNvy * m_nvx; - float px, py, qx, qy; - - // If the segments are parallel, use bevel join. - if (qFuzzyIsNull(xprod)) - break; - - // Find the corners of the previous and next segment to join. - if (xprod < 0) { - px = m_vertices.at(count - 2); - py = m_vertices.at(count - 1); - qx = m_cx - m_nvx; - qy = m_cy - m_nvy; - } else { - px = m_vertices.at(count - 4); - py = m_vertices.at(count - 3); - qx = m_cx + m_nvx; - qy = m_cy + m_nvy; - } - - // Find intersection point. - float pu = px * prevNvx + py * prevNvy; - float qv = qx * m_nvx + qy * m_nvy; - float ix = (m_nvy * pu - prevNvy * qv) / xprod; - float iy = (prevNvx * qv - m_nvx * pu) / xprod; - - // Check that the distance to the intersection point is less than the miter limit. - if ((ix - px) * (ix - px) + (iy - py) * (iy - py) <= m_miter_limit * m_miter_limit) { - m_vertices.add(ix); - m_vertices.add(iy); - m_vertices.add(ix); - m_vertices.add(iy); - } - // else - // Do a plain bevel join if the miter limit is exceeded or if - // the lines are parallel. This is not what the raster - // engine's stroker does, but it is both faster and similar to - // what some other graphics API's do. - - break; } - case Qt::RoundJoin: { - QVarLengthArray points; - int count = m_vertices.size(); - float prevNvx = m_vertices.at(count - 2) - m_cx; - float prevNvy = m_vertices.at(count - 1) - m_cy; - if (m_nvx * prevNvy - m_nvy * prevNvx < 0) { - arcPoints(0, 0, m_nvx, m_nvy, -prevNvx, -prevNvy, points); - for (int i = points.size() / 2; i > 0; --i) - emitLineSegment(m_cx, m_cy, points[2 * i - 2], points[2 * i - 1]); - } else { - arcPoints(0, 0, -prevNvx, -prevNvy, m_nvx, m_nvy, points); - for (int i = 0; i < points.size() / 2; ++i) - emitLineSegment(m_cx, m_cy, points[2 * i + 0], points[2 * i + 1]); - } - break; } - default: break; // gcc warn-- - } - - emitLineSegment(m_cx, m_cy, m_nvx, m_nvy); -} - QT_END_NAMESPACE #endif -- cgit v0.12 From 2b6af778f3b5bd32e95332f95b9eda7c26e63635 Mon Sep 17 00:00:00 2001 From: Oswald Buddenhagen Date: Thu, 26 Nov 2009 13:02:44 +0100 Subject: ignore Alt+Space acelerators - useless and too many false positives Task-number: QTBUG-4429 --- tools/linguist/linguist/mainwindow.cpp | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/tools/linguist/linguist/mainwindow.cpp b/tools/linguist/linguist/mainwindow.cpp index 5c3aaa1..f56c966 100644 --- a/tools/linguist/linguist/mainwindow.cpp +++ b/tools/linguist/linguist/mainwindow.cpp @@ -2348,6 +2348,17 @@ void MainWindow::updatePhraseDicts() m_phraseView->update(); } +static bool haveMnemonic(const QString &str) +{ + QString mnemonic = QKeySequence::mnemonic(str); + if (mnemonic == QLatin1String("Alt+Space")) { + // "Nobody" ever really uses these, and they are highly annoying + // because we get a lot of false positives. + return false; + } + return !mnemonic.isEmpty(); +} + void MainWindow::updateDanger(const MultiDataIndex &index, bool verbose) { MultiDataIndex curIdx = index; @@ -2379,10 +2390,10 @@ void MainWindow::updateDanger(const MultiDataIndex &index, bool verbose) } if (m_ui.actionAccelerators->isChecked()) { - bool sk = !QKeySequence::mnemonic(source).isEmpty(); + bool sk = haveMnemonic(source); bool tk = true; for (int i = 0; i < translations.count() && tk; ++i) { - tk &= !QKeySequence::mnemonic(translations[i]).isEmpty(); + tk &= haveMnemonic(translations[i]); } if (!sk && tk) { -- cgit v0.12 From 4160adc44a512a97d333227cfdde0648fb4132a9 Mon Sep 17 00:00:00 2001 From: Janne Anttila Date: Thu, 26 Nov 2009 14:50:37 +0200 Subject: Fixed context menu placement partially outside screen bug in Symbian. In style demo example when spinbox was long tapped, the context menu was placed partially outside screen. The preconditions for bug were: 1. Tap position is near screen right edge 2. Minimum space width requested by context menu is > sreen width The new (simplified) logic is as follows: 1. If menus right edge in requested position is outside screen right edge, the menu is moved to left enough to fit on screen. i.e. if (tap position + menu width > screen right ) x = screen right - menu width 2. As a result of above statement the x position might go outside left boundary of screen. This is fixed by next statements if( x < screen left ) x = screen left Task-number: QTBUG-6164 Reviewed-by: Alessandro Portale --- src/gui/widgets/qmenu.cpp | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/gui/widgets/qmenu.cpp b/src/gui/widgets/qmenu.cpp index 761a060..2e27226 100644 --- a/src/gui/widgets/qmenu.cpp +++ b/src/gui/widgets/qmenu.cpp @@ -229,7 +229,7 @@ void QMenuPrivate::updateActionRects() const Q_Q(const QMenu); if (!itemsDirty) return; - + q->ensurePolished(); //let's reinitialize the buffer @@ -292,7 +292,7 @@ void QMenuPrivate::updateActionRects() const if (!action->isVisible() || (collapsibleSeparators && previousWasSeparator && action->isSeparator())) continue; // we continue, this action will get an empty QRect - + previousWasSeparator = action->isSeparator(); //let the style modify the above size.. @@ -1139,7 +1139,7 @@ void QMenuPrivate::_q_actionTriggered() //we check the parent hierarchy QList< QPointer > list; for(QWidget *widget = q->parentWidget(); widget; ) { - if (qobject_cast(widget) + if (qobject_cast(widget) #ifndef QT_NO_MENUBAR || qobject_cast(widget) #endif @@ -1306,7 +1306,7 @@ void QMenu::initStyleOption(QStyleOptionMenuItem *option, const QAction *action) the addAction(), addActions() and insertAction() functions. An action is represented vertically and rendered by QStyle. In addition, actions can have a text label, an optional icon drawn on the very left side, - and shortcut key sequence such as "Ctrl+X". + and shortcut key sequence such as "Ctrl+X". The existing actions held by a menu can be found with actions(). @@ -1906,9 +1906,9 @@ void QMenu::popup(const QPoint &p, QAction *atAction) pos.setX(qMax(p.x()-size.width(), screen.right()-desktopFrame-size.width()+1)); } else { if (pos.x()+size.width()-1 > screen.right()-desktopFrame) - pos.setX(qMin(p.x()+size.width(), screen.right()-desktopFrame-size.width()+1)); + pos.setX(screen.right()-desktopFrame-size.width()+1); if (pos.x() < screen.left()+desktopFrame) - pos.setX(qMax(p.x(), screen.left() + desktopFrame)); + pos.setX(screen.left() + desktopFrame); } if (pos.y() + size.height() - 1 > screen.bottom() - desktopFrame) { if(snapToMouse) -- cgit v0.12 From 705880f0045ac39140f980d69aec68869213e379 Mon Sep 17 00:00:00 2001 From: Alexis Menard Date: Thu, 26 Nov 2009 13:47:34 +0100 Subject: Fix a crash in KDE/Plasma with QGraphicsView. TopLevel list of items was corrupted. This nasty bug was triggered when the index sort the top level list of items. We forgot to set the flag topLevelSequentialOrdering to false so when an item was removed from the top level list it was using the sibling index which can be not valid anymore since the list is not sorted by sequential order. So it let some dangling pointers in the list which make processDirtyItemRecursive crash the next paint event. Reviewed-by:bnilsen Reviewed-by:andreas --- src/gui/graphicsview/qgraphicsscene_p.h | 3 ++- tests/auto/qgraphicsscene/tst_qgraphicsscene.cpp | 32 ++++++++++++++++++++++++ 2 files changed, 34 insertions(+), 1 deletion(-) diff --git a/src/gui/graphicsview/qgraphicsscene_p.h b/src/gui/graphicsview/qgraphicsscene_p.h index a1d0496..69e4d5b 100644 --- a/src/gui/graphicsview/qgraphicsscene_p.h +++ b/src/gui/graphicsview/qgraphicsscene_p.h @@ -78,7 +78,7 @@ class QGraphicsSceneIndex; class QGraphicsView; class QGraphicsWidget; -class QGraphicsScenePrivate : public QObjectPrivate +class Q_AUTOTEST_EXPORT QGraphicsScenePrivate : public QObjectPrivate { Q_DECLARE_PUBLIC(QGraphicsScene) public: @@ -265,6 +265,7 @@ public: { if (needSortTopLevelItems) { qSort(topLevelItems.begin(), topLevelItems.end(), qt_notclosestLeaf); + topLevelSequentialOrdering = false; needSortTopLevelItems = false; } } diff --git a/tests/auto/qgraphicsscene/tst_qgraphicsscene.cpp b/tests/auto/qgraphicsscene/tst_qgraphicsscene.cpp index 20d9eb8..a8017ff 100644 --- a/tests/auto/qgraphicsscene/tst_qgraphicsscene.cpp +++ b/tests/auto/qgraphicsscene/tst_qgraphicsscene.cpp @@ -46,6 +46,8 @@ #endif #include +#include +#include #include #include "../../shared/util.h" @@ -269,6 +271,7 @@ private slots: void initialFocus(); void polishItems(); void isActive(); + void siblingIndexAlwaysValid(); // task specific tests below me void task139710_bspTreeCrash(); @@ -4181,6 +4184,35 @@ void tst_QGraphicsScene::isActive() } +void tst_QGraphicsScene::siblingIndexAlwaysValid() +{ + QGraphicsScene scene; + + QGraphicsWidget *parent = new QGraphicsWidget; + parent->setZValue(350); + parent->setGeometry(0, 0, 100, 100); + QGraphicsWidget *parent2 = new QGraphicsWidget; + parent2->setGeometry(10, 10, 50, 50); + QGraphicsWidget *child = new QGraphicsWidget(parent2); + child->setGeometry(15, 15, 25, 25); + child->setZValue(150); + //Both are top level + scene.addItem(parent); + scene.addItem(parent2); + + //Then we make the child a top level + child->setParentItem(0); + + //This is trigerred by a repaint... + QGraphicsScenePrivate::get(&scene)->index->estimateTopLevelItems(QRectF(), Qt::AscendingOrder); + + delete child; + + //If there are in the list that's bad, we crash... + QVERIFY(!QGraphicsScenePrivate::get(&scene)->topLevelItems.contains(static_cast(child))); + +} + void tst_QGraphicsScene::taskQTBUG_5904_crashWithDeviceCoordinateCache() { QGraphicsScene scene; -- cgit v0.12 From d014d49c88d4fa31c46afb2c252e481177b30a55 Mon Sep 17 00:00:00 2001 From: Daniil Ivanov Date: Thu, 26 Nov 2009 14:44:09 +0100 Subject: Fixes performance problem with scribble avoiding to redraw whole screen on every MotionNotify event. Merge-request: 2210 Reviewed-by: Eskil Abrahamsen Blomfeldt --- examples/widgets/scribble/scribblearea.cpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/examples/widgets/scribble/scribblearea.cpp b/examples/widgets/scribble/scribblearea.cpp index 6c9d8aa..2bc2a69 100644 --- a/examples/widgets/scribble/scribblearea.cpp +++ b/examples/widgets/scribble/scribblearea.cpp @@ -139,11 +139,12 @@ void ScribbleArea::mouseReleaseEvent(QMouseEvent *event) } //! [12] //! [13] -void ScribbleArea::paintEvent(QPaintEvent * /* event */) +void ScribbleArea::paintEvent(QPaintEvent *event) //! [13] //! [14] { QPainter painter(this); - painter.drawImage(QPoint(0, 0), image); + QRect dirtyRect = event->rect(); + painter.drawImage(dirtyRect, image, dirtyRect); } //! [14] -- cgit v0.12 From 88b9c6eb3f1dde9997d5e824450c9eaa2a36f8d5 Mon Sep 17 00:00:00 2001 From: Stephen Kelly Date: Thu, 26 Nov 2009 16:00:13 +0100 Subject: Don't crash via proxy model when moving QModelIndexes The layoutAboutToBeChanged signal gives proxies a chance to persist QModelIndexes. The d->itemsAboutToBeMoved method is part of the process of moving the persistent indexes. d->itemsAboutToBeMoved must be called after layoutAboutToBeChanged. Otherwise persistent indexes will not be updated. Merge-request: 2219 Reviewed-by: Olivier Goffart --- src/corelib/kernel/qabstractitemmodel.cpp | 2 +- .../qabstractitemmodel/tst_qabstractitemmodel.cpp | 21 +++++++++++++++++++++ 2 files changed, 22 insertions(+), 1 deletion(-) diff --git a/src/corelib/kernel/qabstractitemmodel.cpp b/src/corelib/kernel/qabstractitemmodel.cpp index 10a61ca..9335085 100644 --- a/src/corelib/kernel/qabstractitemmodel.cpp +++ b/src/corelib/kernel/qabstractitemmodel.cpp @@ -2546,9 +2546,9 @@ bool QAbstractItemModel::beginMoveRows(const QModelIndex &sourceParent, int sour int destinationLast = destinationChild + (sourceLast - sourceFirst); d->changes.push(QAbstractItemModelPrivate::Change(destinationParent, destinationChild, destinationLast)); - d->itemsAboutToBeMoved(sourceParent, sourceFirst, sourceLast, destinationParent, destinationChild, Qt::Vertical); emit rowsAboutToBeMoved(sourceParent, sourceFirst, sourceLast, destinationParent, destinationChild); emit layoutAboutToBeChanged(); + d->itemsAboutToBeMoved(sourceParent, sourceFirst, sourceLast, destinationParent, destinationChild, Qt::Vertical); return true; } diff --git a/tests/auto/qabstractitemmodel/tst_qabstractitemmodel.cpp b/tests/auto/qabstractitemmodel/tst_qabstractitemmodel.cpp index 413419d..3736813 100644 --- a/tests/auto/qabstractitemmodel/tst_qabstractitemmodel.cpp +++ b/tests/auto/qabstractitemmodel/tst_qabstractitemmodel.cpp @@ -112,6 +112,8 @@ private slots: void testMoveWithinOwnRange_data(); void testMoveWithinOwnRange(); + void testMoveThroughProxy(); + void testReset(); @@ -1112,6 +1114,25 @@ void tst_QAbstractItemModel::testMoveSameParentUp() } } +void tst_QAbstractItemModel::testMoveThroughProxy() +{ + QSortFilterProxyModel *proxy = new QSortFilterProxyModel(this); + proxy->setSourceModel(m_model); + + QList persistentList; + + persistentList.append(proxy->index(0, 0)); + persistentList.append(proxy->index(0, 0, proxy->mapFromSource(m_model->index(5, 0)))); + + ModelMoveCommand *moveCommand = new ModelMoveCommand(m_model, this); + moveCommand->setNumCols(4); + moveCommand->setAncestorRowNumbers(QList() << 5); + moveCommand->setStartRow(0); + moveCommand->setEndRow(0); + moveCommand->setDestRow(0); + moveCommand->doCommand(); +} + void tst_QAbstractItemModel::testMoveToGrandParent_data() { QTest::addColumn("startRow"); -- cgit v0.12 From e8d7d2172627dd3cac8b0cc3165ed371b524feb4 Mon Sep 17 00:00:00 2001 From: Gabriel de Dietrich Date: Thu, 26 Nov 2009 12:41:58 +0100 Subject: QSortProxyModel: Crash when changing model with 2-level proxy and selected items The index mapping to the base model was being cleared before the persistant model indices. Reviewed-by: Olivier Task-number: QTBUG-6237 --- src/gui/itemviews/qsortfilterproxymodel.cpp | 6 +++- .../tst_qsortfilterproxymodel.cpp | 37 ++++++++++++++++++++++ 2 files changed, 42 insertions(+), 1 deletion(-) diff --git a/src/gui/itemviews/qsortfilterproxymodel.cpp b/src/gui/itemviews/qsortfilterproxymodel.cpp index f1ae3d2..fc82f30 100644 --- a/src/gui/itemviews/qsortfilterproxymodel.cpp +++ b/src/gui/itemviews/qsortfilterproxymodel.cpp @@ -1153,6 +1153,8 @@ void QSortFilterProxyModelPrivate::_q_sourceAboutToBeReset() { Q_Q(QSortFilterProxyModel); q->beginResetModel(); + invalidatePersistentIndexes(); + clear_mapping(); } void QSortFilterProxyModelPrivate::_q_sourceReset() @@ -1470,6 +1472,8 @@ void QSortFilterProxyModel::setSourceModel(QAbstractItemModel *sourceModel) { Q_D(QSortFilterProxyModel); + beginResetModel(); + disconnect(d->model, SIGNAL(dataChanged(QModelIndex,QModelIndex)), this, SLOT(_q_sourceDataChanged(QModelIndex,QModelIndex))); @@ -1551,7 +1555,7 @@ void QSortFilterProxyModel::setSourceModel(QAbstractItemModel *sourceModel) connect(d->model, SIGNAL(modelReset()), this, SLOT(_q_sourceReset())); d->clear_mapping(); - reset(); + endResetModel(); if (d->update_source_sort_column() && d->dynamic_sortfilter) d->sort(); } diff --git a/tests/auto/qsortfilterproxymodel/tst_qsortfilterproxymodel.cpp b/tests/auto/qsortfilterproxymodel/tst_qsortfilterproxymodel.cpp index e99e9d6..b7839f7 100644 --- a/tests/auto/qsortfilterproxymodel/tst_qsortfilterproxymodel.cpp +++ b/tests/auto/qsortfilterproxymodel/tst_qsortfilterproxymodel.cpp @@ -135,6 +135,7 @@ private slots: void task251296_hiddenChildren(); void task252507_mapFromToSource(); void task255652_removeRowsRecursive(); + void taskQTBUG_6205_doubleProxySelectionSetSourceModel(); protected: void buildHierarchy(const QStringList &data, QAbstractItemModel *model); @@ -2815,5 +2816,41 @@ void tst_QSortFilterProxyModel::task255652_removeRowsRecursive() delete pItem11; } +void tst_QSortFilterProxyModel::taskQTBUG_6205_doubleProxySelectionSetSourceModel() +{ + QStandardItemModel *model1 = new QStandardItemModel; + QStandardItem *parentItem = model1->invisibleRootItem(); + for (int i = 0; i < 4; ++i) { + QStandardItem *item = new QStandardItem(QString("model1 item %0").arg(i)); + parentItem->appendRow(item); + parentItem = item; + } + + QStandardItemModel *model2 = new QStandardItemModel; + QStandardItem *parentItem2 = model2->invisibleRootItem(); + for (int i = 0; i < 4; ++i) { + QStandardItem *item = new QStandardItem(QString("model2 item %0").arg(i)); + parentItem2->appendRow(item); + parentItem2 = item; + } + + QSortFilterProxyModel *toggleProxy = new QSortFilterProxyModel; + toggleProxy->setSourceModel(model1); + + QSortFilterProxyModel *proxyModel = new QSortFilterProxyModel; + proxyModel->setSourceModel(toggleProxy); + + QModelIndex mi = proxyModel->index(0, 0, proxyModel->index(0, 0, proxyModel->index(0, 0))); + QItemSelectionModel ism(proxyModel); + ism.select(mi, QItemSelectionModel::Select); + QModelIndexList mil = ism.selectedIndexes(); + QCOMPARE(mil.count(), 1); + QCOMPARE(mil.first(), mi); + + toggleProxy->setSourceModel(model2); + // No crash, it's good news! + QVERIFY(ism.selection().isEmpty()); +} + QTEST_MAIN(tst_QSortFilterProxyModel) #include "tst_qsortfilterproxymodel.moc" -- cgit v0.12 From 6c50eb3cbd4857e830daa0cc043d834bdfa4bd06 Mon Sep 17 00:00:00 2001 From: Oswald Buddenhagen Date: Thu, 26 Nov 2009 22:20:37 +0100 Subject: fix crash on closing all files under certain circumstances after all, it is no good idea to announce the removal of all columns just to let the view headers adjust themselves - it also makes the views emit currentItemChanged() which has some undesirable side effects. so don't do it an fix the header manually. --- tools/linguist/linguist/mainwindow.cpp | 14 ++++++++++---- tools/linguist/linguist/mainwindow.h | 1 + tools/linguist/linguist/messagemodel.cpp | 7 ------- 3 files changed, 11 insertions(+), 11 deletions(-) diff --git a/tools/linguist/linguist/mainwindow.cpp b/tools/linguist/linguist/mainwindow.cpp index f56c966..383f5aa 100644 --- a/tools/linguist/linguist/mainwindow.cpp +++ b/tools/linguist/linguist/mainwindow.cpp @@ -305,8 +305,6 @@ MainWindow::MainWindow() m_contextView->setModel(m_sortedContextsModel); m_contextView->header()->setMovable(false); m_contextView->setColumnHidden(0, true); - m_contextView->header()->setResizeMode(1, QHeaderView::Stretch); - m_contextView->header()->setResizeMode(2, QHeaderView::ResizeToContents); m_contextView->header()->setStretchLastSection(false); m_contextDock->setWidget(m_contextView); @@ -335,8 +333,6 @@ MainWindow::MainWindow() m_messageView->setModel(m_sortedMessagesModel); m_messageView->header()->setMovable(false); m_messageView->setColumnHidden(0, true); - m_messageView->setColumnHidden(2, true); - // last visible column auto-stretches m_messagesDock->setWidget(m_messageView); @@ -443,6 +439,7 @@ MainWindow::MainWindow() statusBar()->addPermanentWidget(m_modifiedLabel); modelCountChanged(); + initViewHeaders(); resetSorting(); connect(m_dataModel, SIGNAL(modifiedChanged(bool)), @@ -509,6 +506,14 @@ MainWindow::~MainWindow() delete m_printer; } +void MainWindow::initViewHeaders() +{ + m_contextView->header()->setResizeMode(1, QHeaderView::Stretch); + m_contextView->header()->setResizeMode(2, QHeaderView::ResizeToContents); + m_messageView->setColumnHidden(2, true); + // last visible column auto-stretches +} + void MainWindow::modelCountChanged() { int mc = m_dataModel->modelCount(); @@ -740,6 +745,7 @@ bool MainWindow::closeAll() m_messageView->setUpdatesEnabled(false); m_dataModel->closeAll(); modelCountChanged(); + initViewHeaders(); recentFiles().closeGroup(); return true; } diff --git a/tools/linguist/linguist/mainwindow.h b/tools/linguist/linguist/mainwindow.h index 8b46893..dc711d8 100644 --- a/tools/linguist/linguist/mainwindow.h +++ b/tools/linguist/linguist/mainwindow.h @@ -179,6 +179,7 @@ private: bool prev(bool checkUnfinished); void updateStatistics(); + void initViewHeaders(); void modelCountChanged(); void setupMenuBar(); void setupToolBars(); diff --git a/tools/linguist/linguist/messagemodel.cpp b/tools/linguist/linguist/messagemodel.cpp index 024fd91..49cd382 100644 --- a/tools/linguist/linguist/messagemodel.cpp +++ b/tools/linguist/linguist/messagemodel.cpp @@ -786,16 +786,9 @@ void MultiDataModel::closeAll() m_numFinished = 0; m_numEditable = 0; m_numMessages = 0; - int delCol = m_dataModels.count(); - m_msgModel->beginRemoveColumns(QModelIndex(), 1, delCol); - for (int i = m_multiContextList.size(); --i >= 0;) { - m_msgModel->beginRemoveColumns(m_msgModel->createIndex(i, 0, 0), 1, delCol); - m_msgModel->endRemoveColumns(); - } qDeleteAll(m_dataModels); m_dataModels.clear(); m_multiContextList.clear(); - m_msgModel->endRemoveColumns(); m_msgModel->reset(); emit allModelsDeleted(); onModifiedChanged(); -- cgit v0.12 From 55bc5eb8b4e5d758f12761e67e063a418afa14a0 Mon Sep 17 00:00:00 2001 From: Rhys Weatherley Date: Fri, 27 Nov 2009 10:58:46 +1000 Subject: Fix infinite recursion in OpenVG scissor-only clipping When a complex transform was set, clip(QVectorPath) would call clip(QRect) with the control point rect, which would then turn around and say "transform is complex, call clip(QVectorPath)", causing an infinite loop until stack crash. Remove the "fall back to vector path" case as it isn't useful for scissor-only clipping. Doesn't affect mask-based clipping. Reviewed-by: Sarah Smith --- src/openvg/qpaintengine_vg.cpp | 12 ------------ 1 file changed, 12 deletions(-) diff --git a/src/openvg/qpaintengine_vg.cpp b/src/openvg/qpaintengine_vg.cpp index ba97d4f..6b829dd 100644 --- a/src/openvg/qpaintengine_vg.cpp +++ b/src/openvg/qpaintengine_vg.cpp @@ -1570,12 +1570,6 @@ void QVGPaintEngine::clip(const QRect &rect, Qt::ClipOperation op) d->dirty |= QPaintEngine::DirtyClipRegion; - // If we have a non-simple transform, then use path-based clipping. - if (op != Qt::NoClip && !clipTransformIsSimple(d->transform)) { - QPaintEngineEx::clip(rect, op); - return; - } - switch (op) { case Qt::NoClip: { @@ -1612,12 +1606,6 @@ void QVGPaintEngine::clip(const QRegion ®ion, Qt::ClipOperation op) d->dirty |= QPaintEngine::DirtyClipRegion; - // If we have a non-simple transform, then use path-based clipping. - if (op != Qt::NoClip && !clipTransformIsSimple(d->transform)) { - QPaintEngineEx::clip(region, op); - return; - } - switch (op) { case Qt::NoClip: { -- cgit v0.12 From 19d0a365dd99dc1a108e58949f7d0f49bac72623 Mon Sep 17 00:00:00 2001 From: Jason McDonald Date: Fri, 27 Nov 2009 10:59:25 +1000 Subject: Minor changelog updates Reviewed-by: Olivier Goffart --- dist/changes-4.6.0 | 30 +++++++++++++++++++++--------- 1 file changed, 21 insertions(+), 9 deletions(-) diff --git a/dist/changes-4.6.0 b/dist/changes-4.6.0 index 887c96f..3e7d33b 100644 --- a/dist/changes-4.6.0 +++ b/dist/changes-4.6.0 @@ -91,9 +91,14 @@ Optimizations QtCore ------ + - QAbstractItemModel + * [MR#972] Added API to move items + * [MR#1072] Added function beginResetModel() / endResetModel() + - QByteArray * New overloads for QByteArray::insert() and QByteArray::prepend(). + * [MR#1286] Added value_type typedef for STL compatibility - QEventDispatcherGlib (internal class) * Fix a regression introduced in 4.5.3 that would cause timers to not @@ -195,6 +200,8 @@ QtGui - QAbstractItemView * [256502] Fixes selectionModel::hasSelection return value after model::reset. + * [MR#1426] Fixes some issues with Shift-selection + * [MR#1668] New QAbstractItemView::setDefaultDropAction - QApplication * [QTBUG-739] Removed internal widgets from QApplication::topLevelWidgets(). @@ -317,6 +324,7 @@ QtGui - QListView * [243335] Fixed the visualRect to return correct values when the widget is not yet shown. + * [MR#666] Fixed selection with Shift-Arrow/Shift-Click in QListView's IconMode - QMainWindow * [226060] Adding actions to a toolbar would always make the next toolbar @@ -422,6 +430,9 @@ QtGui * [240325] Even with wrap mode set to Qt::TextWordWrap, the layout would sometimes break outside word boundaries when floating objects affected the width available to the text. + * [MR#681] Added support for roman numbering for lists + * [MR#1753] Fixed escaping HTML attributes QTextDocument::toHtml() + - QTextLayout * [QTBUG-4468] Count tabs as multiple characters when applying a fixed @@ -443,6 +454,7 @@ QtGui - QTreeWidget * [253109] Shows the widget when calling setItemWidget. + * [MR#1393] Use stable sorting. - QWidget * Added inputMethodHints property. @@ -612,7 +624,7 @@ QtWebKit - QWebElement * New class; introduced to implement DOM like operations on a web page. - + - QWebFrame * New properties for an URL and a focus management. * New signals delivering current loading status. @@ -860,17 +872,17 @@ Qt for Embedded Linux - Phonon on Windows * Now much more reliable when reading a file through a QIODevice. - * If Video Mixing Renderer 9 is not available, falls back to software + * If Video Mixing Renderer 9 is not available, falls back to software rendering. * Fixed a flicker issue when switching source with a transition time of 0 - - - [QTBUG-3620] Fixed bug on X11 that caused bitmap fonts to become so small - it was unreadable when printed or presented in a print preview widget. - - - [QTBUG-4445] Fixed bug on Windows that caused problems when printing - text where several characters were represented by a single glyph, e.g. + + - [QTBUG-3620] Fixed bug on X11 that caused bitmap fonts to become so small + it was unreadable when printed or presented in a print preview widget. + + - [QTBUG-4445] Fixed bug on Windows that caused problems when printing + text where several characters were represented by a single glyph, e.g. a double 't' with the Calibri font. - + - EGL and OpenGL/ES * Protect the use of version-specific EGL symbols with #ifdef's. * Make sure an EGL context is current when resolving GL extensions. -- cgit v0.12 From 55ed03bdc8a1c54ead6341deb6c5c2b0b14cdfa3 Mon Sep 17 00:00:00 2001 From: Janne Anttila Date: Fri, 27 Nov 2009 07:53:56 +0200 Subject: Fixed typo in Symbian installation instructions. Task-number: QTBUG-6175 Reviewed-by: TrustMe --- doc/src/getting-started/installation.qdoc | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/doc/src/getting-started/installation.qdoc b/doc/src/getting-started/installation.qdoc index 057629d..58059d1 100644 --- a/doc/src/getting-started/installation.qdoc +++ b/doc/src/getting-started/installation.qdoc @@ -423,7 +423,7 @@ in the \l{Qt for Windows CE Requirements} document. "Control Panel->System->Advanced->Environment variables" and for older versions by editing \c{c:\autoexec.bat}. - Make sure the enviroment variables for your compiler are set. + Make sure the enviroment variables for your compiler are set. Visual Studio includes \c{vcvars32.bat} for that purpose - or simply use the "Visual Studio Command Prompt" from the Start menu. @@ -530,7 +530,7 @@ in the \l{Qt for the Symbian platform Requirements} document. \snippet doc/src/snippets/code/doc_src_installation.qdoc 25 - To run the demos on the emulator simply navigate to the directory of the demo + To run the demos on the emulator simply navigate to the directory of the demo you want to see and run: \snippet doc/src/snippets/code/doc_src_installation.qdoc 27 @@ -554,7 +554,7 @@ Symbian platform, in the \l{Qt for the Symbian platform Requirements} document. \note \bold {This document describes how to install and configure Qt for -the Symbian platform from scratch. +the Symbian platform from scratch. If you are using pre-built binaries, follow the instructions given in the \l{Installing Qt on the Symbian platform from a Binary Package} document.} @@ -616,7 +616,7 @@ If you are using pre-built binaries, follow the instructions given in the \snippet doc/src/snippets/code/doc_src_installation.qdoc 31 to build the tools using MinGW, and the libraries using SBSv2. - SBSv2 also known as a (\l{http://developer.symbian.org/wiki/index.php/Introduction_to_RAPTOR} {Raptor}) + SBSv2 (also known as \l{http://developer.symbian.org/wiki/index.php/Introduction_to_RAPTOR} {Raptor}) is a next-generation Symbian build system. SBSv2 is not officially supported by any of the S60 SDKs currently available from Forum Nokia. @@ -641,8 +641,8 @@ If you are using pre-built binaries, follow the instructions given in the \snippet doc/src/snippets/code/doc_src_installation.qdoc 29 - \note You will need to supply certificate that allows installation - of binaries with "All -Tcb" capability to your device. + \note You will need to supply certificate that allows installation + of binaries with "All -Tcb" capability to your device. Similarly, install fluidlauncher to the device: @@ -651,7 +651,7 @@ If you are using pre-built binaries, follow the instructions given in the This will create a self-signed \c fluidlauncher_armv5_urel.sis and install it to your device. - To run the demos on the emulator simply navigate to the directory of the demo + To run the demos on the emulator simply navigate to the directory of the demo you want to see and run: \snippet doc/src/snippets/code/doc_src_installation.qdoc 27 @@ -827,7 +827,7 @@ If you are using pre-built binaries, follow the instructions given in the when building Qt from its source code. On Debian-based GNU/Linux systems, for example, we recommend that you install the following development packages: - + \list \o libfontconfig1-dev \o libfreetype6-dev @@ -850,7 +850,7 @@ If you are using pre-built binaries, follow the instructions given in the The configure script will autodetect if OpenGL headers and libraries are installed on your system, and if so, it will include the QtOpenGL module in the Qt library. - + If your OpenGL headers or libraries are placed in a non-standard directory, you may need to change the \c QMAKE_INCDIR_OPENGL and/or \c QMAKE_LIBDIR_OPENGL in the config file for your system. @@ -954,7 +954,7 @@ If you are using pre-built binaries, follow the instructions given in the \table \header \o{1,2} Architecture \o{1,2} Compiler \o{2,1} QtCore \o{2,1} QtGui \o{2,1} QtNetwork \o{2,1} QtWebKit - \header \o Minimal \o Normal \o Minimal \o Normal \o Minimal \o Normal \o Minimal \o Normal + \header \o Minimal \o Normal \o Minimal \o Normal \o Minimal \o Normal \o Minimal \o Normal \row \o linux-x86-g++ \o GCC 4.2.4 \o 1.7M \o 2.7M \o 3.3M \o 9.9M \o 653K \o 1.1M \o N/A \o 17M \row \o linux-arm-g++ \o GCC 4.1.1 \o 1.9M \o 3.2M \o 4.1M \o 11M \o 507K \o 1.0M \o N/A \o 17M \row \o linux-mips-g++ (MIPS32) @@ -984,7 +984,7 @@ If you are using pre-built binaries, follow the instructions given in the Qt for the Symbian platform requires the following software installed on your development PC: \list - \o \l{http://www.forum.nokia.com/main/resources/tools_and_sdks/carbide_cpp/}{Carbide.c++ v2.0.0 or higher} + \o \l{http://www.forum.nokia.com/main/resources/tools_and_sdks/carbide_cpp/}{Carbide.c++ v2.0.0 or higher} \list \o \bold{Note:} It may be necessary to update the Carbide compiler. See \l{http://pepper.troll.no/s60prereleases/patches/}{here} for instructions how to check your @@ -1006,7 +1006,7 @@ If you are using pre-built binaries, follow the instructions given in the \o \bold{Note:} This is not required if you are using pre-built binary package. \endlist \o Building Qt libraries requires \l{http://www.arm.com/products/DevTools/RVCT.html}{RVCT} 2.2 [build 686] or later, - which is not available free of charge. + which is not available free of charge. \endlist Running Qt on real device requires the following packages to be installed on your device. -- cgit v0.12 From 9401bfd65309da360df6c2bda5f910b1507e7888 Mon Sep 17 00:00:00 2001 From: Gabriel de Dietrich Date: Fri, 27 Nov 2009 09:26:33 +0100 Subject: Fixed non-compiling Q*SpinBox auto-tests Reviewed-by: Olivier --- tests/auto/qdoublespinbox/tst_qdoublespinbox.cpp | 3 ++- tests/auto/qspinbox/tst_qspinbox.cpp | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/tests/auto/qdoublespinbox/tst_qdoublespinbox.cpp b/tests/auto/qdoublespinbox/tst_qdoublespinbox.cpp index 7d7453b..00ebed0 100644 --- a/tests/auto/qdoublespinbox/tst_qdoublespinbox.cpp +++ b/tests/auto/qdoublespinbox/tst_qdoublespinbox.cpp @@ -1050,7 +1050,6 @@ void tst_QDoubleSpinBox::taskQTBUG_5008_textFromValueAndValidate() { class DecoratedSpinBox : public QDoubleSpinBox { - friend class tst_QDoubleSpinBox; public: DecoratedSpinBox() { @@ -1064,6 +1063,8 @@ void tst_QDoubleSpinBox::taskQTBUG_5008_textFromValueAndValidate() { return locale().toString(value); } + + using QDoubleSpinBox::lineEdit; } spinbox; spinbox.show(); spinbox.activateWindow(); diff --git a/tests/auto/qspinbox/tst_qspinbox.cpp b/tests/auto/qspinbox/tst_qspinbox.cpp index d2fe2ac..655de15 100644 --- a/tests/auto/qspinbox/tst_qspinbox.cpp +++ b/tests/auto/qspinbox/tst_qspinbox.cpp @@ -1010,7 +1010,6 @@ void tst_QSpinBox::taskQTBUG_5008_textFromValueAndValidate() { class DecoratedSpinBox : public QSpinBox { - friend class tst_QSpinBox; public: DecoratedSpinBox() { @@ -1024,6 +1023,8 @@ void tst_QSpinBox::taskQTBUG_5008_textFromValueAndValidate() { return locale().toString(value); } + + using QSpinBox::lineEdit; } spinbox; spinbox.show(); spinbox.activateWindow(); -- cgit v0.12 From f50cfa3a5a6b8408276e540a52f4232568c871fa Mon Sep 17 00:00:00 2001 From: Eskil Abrahamsen Blomfeldt Date: Fri, 27 Nov 2009 09:37:37 +0100 Subject: Fix compilation on Windows CE Commit 6ef5b4485b9fe5a9d25d2d9b5e67f110fb728a8b broke compilation on Windows CE by moving code out from a #ifndef Q_WS_WINCE block. Reviewed-by: Rohan McGovern --- src/gui/text/qfontengine_win.cpp | 2 ++ src/gui/text/qfontengine_win_p.h | 2 ++ 2 files changed, 4 insertions(+) diff --git a/src/gui/text/qfontengine_win.cpp b/src/gui/text/qfontengine_win.cpp index 18851b7..7ec8e31 100644 --- a/src/gui/text/qfontengine_win.cpp +++ b/src/gui/text/qfontengine_win.cpp @@ -485,6 +485,7 @@ glyph_metrics_t QFontEngineWin::boundingBox(const QGlyphLayout &glyphs) return glyph_metrics_t(0, -tm.tmAscent, w, tm.tmHeight, w, 0); } +#ifndef Q_WS_WINCE bool QFontEngineWin::getOutlineMetrics(glyph_t glyph, const QTransform &t, glyph_metrics_t *metrics) const { Q_ASSERT(metrics != 0); @@ -536,6 +537,7 @@ bool QFontEngineWin::getOutlineMetrics(glyph_t glyph, const QTransform &t, glyph return false; } } +#endif glyph_metrics_t QFontEngineWin::boundingBox(glyph_t glyph, const QTransform &t) { diff --git a/src/gui/text/qfontengine_win_p.h b/src/gui/text/qfontengine_win_p.h index 43e1f12..bab71c9 100644 --- a/src/gui/text/qfontengine_win_p.h +++ b/src/gui/text/qfontengine_win_p.h @@ -109,7 +109,9 @@ public: int getGlyphIndexes(const QChar *ch, int numChars, QGlyphLayout *glyphs, bool mirrored) const; void getCMap(); +#ifndef Q_WS_WINCE bool getOutlineMetrics(glyph_t glyph, const QTransform &t, glyph_metrics_t *metrics) const; +#endif QString _name; HFONT hfont; -- cgit v0.12 From 583b1529894aca5e9ffa353f0547dfb4b8b0ab21 Mon Sep 17 00:00:00 2001 From: Kim Motoyoshi Kalland Date: Fri, 27 Nov 2009 10:42:47 +0100 Subject: Fixed memory leak in QImagePixmapCleanupHooks. The QImagePixmapCleanupHooks instance was never deleted. Fixed by making it a Q_GLOBAL_STATIC. Task-number: QTBUG-6116 Reviewed-by: Trond --- src/gui/image/qimagepixmapcleanuphooks.cpp | 28 ++++++++-------------------- src/gui/image/qimagepixmapcleanuphooks_p.h | 3 --- 2 files changed, 8 insertions(+), 23 deletions(-) diff --git a/src/gui/image/qimagepixmapcleanuphooks.cpp b/src/gui/image/qimagepixmapcleanuphooks.cpp index 35322e9..650075b 100644 --- a/src/gui/image/qimagepixmapcleanuphooks.cpp +++ b/src/gui/image/qimagepixmapcleanuphooks.cpp @@ -55,20 +55,11 @@ Q_GUI_EXPORT _qt_pixmap_cleanup_hook_64 qt_pixmap_cleanup_hook_64 = 0; Q_GUI_EXPORT _qt_image_cleanup_hook qt_image_cleanup_hook = 0; Q_GUI_EXPORT _qt_image_cleanup_hook_64 qt_image_cleanup_hook_64 = 0; - -QImagePixmapCleanupHooks* qt_image_and_pixmap_cleanup_hooks = 0; - - -QImagePixmapCleanupHooks::QImagePixmapCleanupHooks() -{ - qt_image_and_pixmap_cleanup_hooks = this; -} +Q_GLOBAL_STATIC(QImagePixmapCleanupHooks, qt_image_and_pixmap_cleanup_hooks) QImagePixmapCleanupHooks *QImagePixmapCleanupHooks::instance() { - if (!qt_image_and_pixmap_cleanup_hooks) - qt_image_and_pixmap_cleanup_hooks = new QImagePixmapCleanupHooks; - return qt_image_and_pixmap_cleanup_hooks; + return qt_image_and_pixmap_cleanup_hooks(); } void QImagePixmapCleanupHooks::addPixmapModificationHook(_qt_pixmap_cleanup_hook_pm hook) @@ -105,9 +96,8 @@ void QImagePixmapCleanupHooks::removeImageHook(_qt_image_cleanup_hook_64 hook) void QImagePixmapCleanupHooks::executePixmapModificationHooks(QPixmap* pm) { - Q_ASSERT(qt_image_and_pixmap_cleanup_hooks); - for (int i = 0; i < qt_image_and_pixmap_cleanup_hooks->pixmapModificationHooks.count(); ++i) - qt_image_and_pixmap_cleanup_hooks->pixmapModificationHooks[i](pm); + for (int i = 0; i < qt_image_and_pixmap_cleanup_hooks()->pixmapModificationHooks.count(); ++i) + qt_image_and_pixmap_cleanup_hooks()->pixmapModificationHooks[i](pm); if (qt_pixmap_cleanup_hook_64) qt_pixmap_cleanup_hook_64(pm->cacheKey()); @@ -115,9 +105,8 @@ void QImagePixmapCleanupHooks::executePixmapModificationHooks(QPixmap* pm) void QImagePixmapCleanupHooks::executePixmapDestructionHooks(QPixmap* pm) { - Q_ASSERT(qt_image_and_pixmap_cleanup_hooks); - for (int i = 0; i < qt_image_and_pixmap_cleanup_hooks->pixmapDestructionHooks.count(); ++i) - qt_image_and_pixmap_cleanup_hooks->pixmapDestructionHooks[i](pm); + for (int i = 0; i < qt_image_and_pixmap_cleanup_hooks()->pixmapDestructionHooks.count(); ++i) + qt_image_and_pixmap_cleanup_hooks()->pixmapDestructionHooks[i](pm); if (qt_pixmap_cleanup_hook_64) qt_pixmap_cleanup_hook_64(pm->cacheKey()); @@ -125,9 +114,8 @@ void QImagePixmapCleanupHooks::executePixmapDestructionHooks(QPixmap* pm) void QImagePixmapCleanupHooks::executeImageHooks(qint64 key) { - Q_ASSERT(qt_image_and_pixmap_cleanup_hooks); - for (int i = 0; i < qt_image_and_pixmap_cleanup_hooks->imageHooks.count(); ++i) - qt_image_and_pixmap_cleanup_hooks->imageHooks[i](key); + for (int i = 0; i < qt_image_and_pixmap_cleanup_hooks()->imageHooks.count(); ++i) + qt_image_and_pixmap_cleanup_hooks()->imageHooks[i](key); if (qt_image_cleanup_hook_64) qt_image_cleanup_hook_64(key); diff --git a/src/gui/image/qimagepixmapcleanuphooks_p.h b/src/gui/image/qimagepixmapcleanuphooks_p.h index 9e490d7..dfc5f28 100644 --- a/src/gui/image/qimagepixmapcleanuphooks_p.h +++ b/src/gui/image/qimagepixmapcleanuphooks_p.h @@ -61,13 +61,10 @@ typedef void (*_qt_image_cleanup_hook_64)(qint64); typedef void (*_qt_pixmap_cleanup_hook_pm)(QPixmap*); class QImagePixmapCleanupHooks; -extern QImagePixmapCleanupHooks* qt_image_and_pixmap_cleanup_hooks; class Q_GUI_EXPORT QImagePixmapCleanupHooks { public: - QImagePixmapCleanupHooks(); - static QImagePixmapCleanupHooks *instance(); static void enableCleanupHooks(const QImage &image); -- cgit v0.12