From 344a4dcfe847dd778c33d1a852381672dd331409 Mon Sep 17 00:00:00 2001 From: Jiang Jiang Date: Fri, 12 Nov 2010 12:50:24 +0100 Subject: Fix text rendering offset for raster engine on Mac Since the bounding box returned by Core Text in smaller than the actual glyph rendered, we have 2 pixels padding around it, as a result, we have to leave 1 pixel above the glyph in glyph cache, so we need to put the text origin 1 pixel lower to draw it. Task-number: QTBUG-15223, QTBUG-15230, QTBUG-15243 Reviewed-by: Gunnar Sletta --- src/gui/text/qfontengine_mac.mm | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/gui/text/qfontengine_mac.mm b/src/gui/text/qfontengine_mac.mm index 7efb1cc..51e18ec 100644 --- a/src/gui/text/qfontengine_mac.mm +++ b/src/gui/text/qfontengine_mac.mm @@ -694,7 +694,7 @@ QImage QCoreTextFontEngine::imageForGlyph(glyph_t glyph, QFixed subPixelPosition CGContextSetFont(ctx, cgFont); qreal pos_x = -br.x.toReal() + subPixelPosition.toReal(); - qreal pos_y = im.height()+br.y.toReal(); + qreal pos_y = im.height() + br.y.toReal() - 1; CGContextSetTextPosition(ctx, pos_x, pos_y); CGSize advance; -- cgit v0.12 From 215deeabaeba359a9b24681f33f99b80060c4fb1 Mon Sep 17 00:00:00 2001 From: Jiang Jiang Date: Fri, 12 Nov 2010 13:56:52 +0100 Subject: Use correct font for menu item shortcuts We used to use kThemeMenuItemCmdKeyFont for drawing menu item shortcuts, however, Apple is using the same font for both menu item text and shortcuts, it's likely that kThemeMenuItemCmdKeyFont is no longer valid. Change it to kThemeMenuItemFont will make the font for shortcuts consistent with other Mac applications. Task-number: QTBUG-15230 Reviewed-by: Fabien Freling --- src/gui/kernel/qapplication_mac.mm | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/gui/kernel/qapplication_mac.mm b/src/gui/kernel/qapplication_mac.mm index e5364d0..3aafeb4 100644 --- a/src/gui/kernel/qapplication_mac.mm +++ b/src/gui/kernel/qapplication_mac.mm @@ -549,7 +549,7 @@ void qt_mac_update_os_settings() FontMap("QTipLabel", kThemeSmallSystemFont), FontMap("QLabel", kThemeSystemFont), FontMap("QToolButton", kThemeSmallSystemFont), - FontMap("QMenuItem", kThemeMenuItemCmdKeyFont), // It doesn't exist, but its unique. + FontMap("QMenuItem", kThemeMenuItemFont), // It doesn't exist, but its unique. FontMap("QComboLineEdit", kThemeViewsFont), // It doesn't exist, but its unique. FontMap("QSmallFont", kThemeSmallSystemFont), // It doesn't exist, but its unique. FontMap("QMiniFont", kThemeMiniSystemFont), // It doesn't exist, but its unique. -- cgit v0.12 From 0d6451ec1f1042dbf8c8cd7f2759e2a385d29696 Mon Sep 17 00:00:00 2001 From: Gunnar Sletta Date: Thu, 11 Nov 2010 15:21:18 +0100 Subject: Introduced new class QAnimationDriver for plugging in what drives animations We need such a concept in place in order to do animations that are driven by vertical sync rather than QTimer, as vertical sync comes constantly at 16.66 ms. This means that animations do will not be jerking... Reviewed-by: bnilsen --- src/corelib/animation/qabstractanimation.cpp | 146 ++++++++++++++++++++- src/corelib/animation/qabstractanimation.h | 31 +++++ src/corelib/animation/qabstractanimation_p.h | 48 +++++-- tests/auto/qpauseanimation/tst_qpauseanimation.cpp | 5 +- 4 files changed, 214 insertions(+), 16 deletions(-) diff --git a/src/corelib/animation/qabstractanimation.cpp b/src/corelib/animation/qabstractanimation.cpp index 641b42b..9add36e 100644 --- a/src/corelib/animation/qabstractanimation.cpp +++ b/src/corelib/animation/qabstractanimation.cpp @@ -166,11 +166,12 @@ Q_GLOBAL_STATIC(QThreadStorage, unifiedTimer) #endif QUnifiedTimer::QUnifiedTimer() : - QObject(), lastTick(0), timingInterval(DEFAULT_TIMER_INTERVAL), + QObject(), defaultDriver(this), lastTick(0), timingInterval(DEFAULT_TIMER_INTERVAL), currentAnimationIdx(0), consistentTiming(false), slowMode(false), slowdownFactor(5.0f), isPauseTimerActive(false), runningLeafAnimations(0) { time.invalidate(); + driver = &defaultDriver; } @@ -247,14 +248,27 @@ void QUnifiedTimer::restartAnimationTimer() qDebug() << runningPauseAnimations; qDebug() << closestPauseAnimationTimeToFinish(); } + driver->stop(); animationTimer.start(closestTimeToFinish, this); isPauseTimerActive = true; - } else if (!animationTimer.isActive() || isPauseTimerActive) { - animationTimer.start(timingInterval, this); + } else if (!driver->isRunning() || isPauseTimerActive) { + driver->start(); isPauseTimerActive = false; } } +void QUnifiedTimer::setTimingInterval(int interval) +{ + timingInterval = interval; + + if (driver->isRunning() && !isPauseTimerActive) { + //we changed the timing interval + driver->stop(); + driver->start(); + } +} + + void QUnifiedTimer::timerEvent(QTimerEvent *event) { //in the case of consistent timing we make sure the orders in which events come is always the same @@ -369,6 +383,129 @@ int QUnifiedTimer::closestPauseAnimationTimeToFinish() return closestTimeToFinish; } +void QUnifiedTimer::installAnimationDriver(QAnimationDriver *d) +{ + if (driver->isRunning()) { + qWarning("QUnifiedTimer: Cannot change animation driver while animations are running"); + return; + } + + if (driver && driver != &defaultDriver) + delete driver; + + driver = d; +} + +/*! + \class QAnimationDriver + + \brief The QAnimationDriver class is used to exchange the mechanism that drives animations. + + The default animation system is driven by a timer that fires at regular intervals. + In some scenarios, it is better to drive the animation based on other synchronization + mechanisms, such as the vertical refresh rate of the screen. + */ + +QAnimationDriver::QAnimationDriver(QObject *parent) + : QObject(*(new QAnimationDriverPrivate), parent) +{ +} + +QAnimationDriver::QAnimationDriver(QAnimationDriverPrivate &dd, QObject *parent) + : QObject(dd, parent) +{ +} + + +/*! + Advances the animation based on the current time. This function should + be continuously called by the driver while the animation is running. + */ +void QAnimationDriver::advance() +{ + QUnifiedTimer *instance = QUnifiedTimer::instance(); + + // update current time on all top level animations + instance->updateAnimationsTime(); + instance->restartAnimationTimer(); +} + + +/*! + Installs this animation driver. The animation driver is thread local and + will only apply for the thread its installed in. + */ +void QAnimationDriver::install() +{ + QUnifiedTimer *timer = QUnifiedTimer::instance(true); + timer->installAnimationDriver(this); +} + +bool QAnimationDriver::isRunning() const +{ + return d_func()->running; +} + + +void QAnimationDriver::start() +{ + Q_D(QAnimationDriver); + if (!d->running) { + started(); + d->running = true; + } +} + + +void QAnimationDriver::stop() +{ + Q_D(QAnimationDriver); + if (d->running) { + stopped(); + d->running = false; + } +} + +/*! + \fn QAnimationDriver::started() + + This function is called by the animation framework to notify the driver + that it should start running. + */ + +/*! + \fn QAnimationDriver::stopped() + + This function is called by the animation framework to notify the driver + that it should stop running. + */ + +/*! + The default animation driver just spins the timer... + */ +QDefaultAnimationDriver::QDefaultAnimationDriver(QUnifiedTimer *timer) + : QAnimationDriver(0), m_unified_timer(timer) +{ +} + +void QDefaultAnimationDriver::timerEvent(QTimerEvent *e) +{ + Q_ASSERT(e->timerId() == m_timer.timerId()); + advance(); +} + +void QDefaultAnimationDriver::started() +{ + m_timer.start(m_unified_timer->timingInterval, this); +} + +void QDefaultAnimationDriver::stopped() +{ + m_timer.stop(); +} + + + void QAbstractAnimationPrivate::setState(QAbstractAnimation::State newState) { Q_Q(QAbstractAnimation); @@ -794,6 +931,9 @@ void QAbstractAnimation::stop() { Q_D(QAbstractAnimation); + if (d->state == Stopped) + return; + d->setState(Stopped); } diff --git a/src/corelib/animation/qabstractanimation.h b/src/corelib/animation/qabstractanimation.h index d3c0d0d..6abe8c1 100644 --- a/src/corelib/animation/qabstractanimation.h +++ b/src/corelib/animation/qabstractanimation.h @@ -54,6 +54,7 @@ QT_MODULE(Core) class QAnimationGroup; class QSequentialAnimationGroup; +class QAnimationDriver; class QAbstractAnimationPrivate; class Q_CORE_EXPORT QAbstractAnimation : public QObject @@ -132,6 +133,36 @@ private: Q_DECLARE_PRIVATE(QAbstractAnimation) }; +class QAnimationDriverPrivate; +class Q_CORE_EXPORT QAnimationDriver : public QObject +{ + Q_OBJECT + Q_DECLARE_PRIVATE(QAnimationDriver) + +public: + QAnimationDriver(QObject *parent); + + void advance(); + void install(); + + bool isRunning() const; + +protected: + virtual void started() = 0; + virtual void stopped() = 0; + + QAnimationDriver(QAnimationDriverPrivate &dd, QObject *parent = 0); + +private: + friend class QUnifiedTimer; + + void start(); + void stop(); +}; + + + + #endif //QT_NO_ANIMATION QT_END_NAMESPACE diff --git a/src/corelib/animation/qabstractanimation_p.h b/src/corelib/animation/qabstractanimation_p.h index d3d4098..bc3746d 100644 --- a/src/corelib/animation/qabstractanimation_p.h +++ b/src/corelib/animation/qabstractanimation_p.h @@ -58,6 +58,7 @@ #include #include #include +#include #ifdef Q_OS_WIN #include @@ -114,6 +115,30 @@ private: Q_DECLARE_PUBLIC(QAbstractAnimation) }; + +class QUnifiedTimer; +class QDefaultAnimationDriver : public QAnimationDriver +{ + Q_OBJECT +public: + QDefaultAnimationDriver(QUnifiedTimer *timer); + void timerEvent(QTimerEvent *e); + + void started(); + void stopped(); + +private: + QBasicTimer m_timer; + QUnifiedTimer *m_unified_timer; +}; + +class Q_CORE_EXPORT QAnimationDriverPrivate : public QObjectPrivate +{ +public: + QAnimationDriverPrivate() : running(false) {} + bool running; +}; + typedef QElapsedTimer ElapsedTimer; class QUnifiedTimer : public QObject @@ -130,14 +155,7 @@ public: static void unregisterAnimation(QAbstractAnimation *animation); //defines the timing interval. Default is DEFAULT_TIMER_INTERVAL - void setTimingInterval(int interval) - { - timingInterval = interval; - if (animationTimer.isActive() && !isPauseTimerActive) { - //we changed the timing interval - animationTimer.start(timingInterval, this); - } - } + void setTimingInterval(int interval); /* this allows to have a consistent timer interval at each tick from the timer @@ -161,11 +179,20 @@ public: */ static void updateAnimationTimer(); + void installAnimationDriver(QAnimationDriver *driver); + + void restartAnimationTimer(); + void updateAnimationsTime(); + protected: void timerEvent(QTimerEvent *); private: - // timer used for all active (running) animations + friend class QDefaultAnimationDriver; + + QAnimationDriver *driver; + QDefaultAnimationDriver defaultDriver; + QBasicTimer animationTimer; // timer used to delay the check if we should start/stop the animation timer QBasicTimer startStopAnimationTimer; @@ -195,9 +222,6 @@ private: void registerRunningAnimation(QAbstractAnimation *animation); void unregisterRunningAnimation(QAbstractAnimation *animation); - void restartAnimationTimer(); - - void updateAnimationsTime(); int closestPauseAnimationTimeToFinish(); }; diff --git a/tests/auto/qpauseanimation/tst_qpauseanimation.cpp b/tests/auto/qpauseanimation/tst_qpauseanimation.cpp index 605cee6..378eb1c 100644 --- a/tests/auto/qpauseanimation/tst_qpauseanimation.cpp +++ b/tests/auto/qpauseanimation/tst_qpauseanimation.cpp @@ -394,7 +394,10 @@ void tst_QPauseAnimation::multipleSequentialGroups() QVERIFY(subgroup3.state() == QAbstractAnimation::Running); QVERIFY(subgroup4.state() == QAbstractAnimation::Running); - QTest::qWait(group.totalDuration() + 100); + // This is a pretty long animation so it tends to get rather out of sync + // when using the consistent timer, so run for an extra half second for good + // measure... + QTest::qWait(group.totalDuration() + 500); #ifdef Q_OS_WIN if (group.state() != QAbstractAnimation::Stopped) -- cgit v0.12 From 0b338187627f874ff27b452fcd67e285cee128c3 Mon Sep 17 00:00:00 2001 From: Kim Motoyoshi Kalland Date: Mon, 15 Nov 2010 10:58:00 +0100 Subject: Compile fix. Reviewed-by: Gunnar --- src/corelib/animation/qabstractanimation_p.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/corelib/animation/qabstractanimation_p.h b/src/corelib/animation/qabstractanimation_p.h index bc3746d..d56c130 100644 --- a/src/corelib/animation/qabstractanimation_p.h +++ b/src/corelib/animation/qabstractanimation_p.h @@ -141,14 +141,14 @@ public: typedef QElapsedTimer ElapsedTimer; -class QUnifiedTimer : public QObject +class Q_CORE_EXPORT QUnifiedTimer : public QObject { private: QUnifiedTimer(); public: //XXX this is needed by dui - static Q_CORE_EXPORT QUnifiedTimer *instance(); + static QUnifiedTimer *instance(); static QUnifiedTimer *instance(bool create); static void registerAnimation(QAbstractAnimation *animation, bool isTopLevel); -- cgit v0.12 From e084fbbe18d771702312d7db65030aaaf18b596b Mon Sep 17 00:00:00 2001 From: Jiang Jiang Date: Tue, 2 Nov 2010 12:36:27 +0100 Subject: Fix cursor position of one digit after RTL text A single digit after RTL text will be considered as RTL because it was treated as Other Neutral (DirON), it can be solved by changing it to DirAN. Task-number: QTBUG-2795 Reviewed-by: Lars Knoll --- src/gui/text/qtextengine.cpp | 2 +- tests/auto/qcomplextext/tst_qcomplextext.cpp | 23 +++++++++++++++++++++++ 2 files changed, 24 insertions(+), 1 deletion(-) diff --git a/src/gui/text/qtextengine.cpp b/src/gui/text/qtextengine.cpp index f4f2168..06eed55 100644 --- a/src/gui/text/qtextengine.cpp +++ b/src/gui/text/qtextengine.cpp @@ -612,7 +612,7 @@ static bool bidiItemize(QTextEngine *engine, QScriptAnalysis *analysis, QBidiCon } else { eor = current; } - dir = QChar::DirON; status.eor = QChar::DirAN; + dir = QChar::DirAN; status.eor = QChar::DirAN; break; case QChar::DirCS: if(status.eor == QChar::DirAN) { diff --git a/tests/auto/qcomplextext/tst_qcomplextext.cpp b/tests/auto/qcomplextext/tst_qcomplextext.cpp index 4a96725..fa8a2d1 100644 --- a/tests/auto/qcomplextext/tst_qcomplextext.cpp +++ b/tests/auto/qcomplextext/tst_qcomplextext.cpp @@ -68,6 +68,7 @@ public slots: private slots: void bidiReorderString_data(); void bidiReorderString(); + void bidiCursor_qtbug2795(); }; tst_QComplexText::tst_QComplexText() @@ -159,6 +160,28 @@ void tst_QComplexText::bidiReorderString() QTEST(visual, "VISUAL"); } +void tst_QComplexText::bidiCursor_qtbug2795() +{ + QString str = QString::fromUtf8("الجزيرة نت"); + QTextLayout l1(str); + + l1.beginLayout(); + QTextLine line1 = l1.createLine(); + l1.endLayout(); + + qreal x1 = line1.cursorToX(0) - line1.cursorToX(str.size()); + + str.append("1"); + QTextLayout l2(str); + l2.beginLayout(); + QTextLine line2 = l2.createLine(); + l2.endLayout(); + + qreal x2 = line2.cursorToX(0) - line2.cursorToX(str.size()); + + // The cursor should remain at the same position after a digit is appended + QVERIFY(x1 == x2); +} QTEST_MAIN(tst_QComplexText) #include "tst_qcomplextext.moc" -- cgit v0.12 From 0f905e860804dbb4182663f1628a359e3c0795b1 Mon Sep 17 00:00:00 2001 From: Yoann Lopes Date: Mon, 15 Nov 2010 14:42:49 +0100 Subject: Chip demo: makes scene interaction easier. It is now possible to zoom in or out using the mouse wheel (while pressing the CTRL key). It is also possible to switch between two pointer modes: select and drag. The first one allows to select items and move them, the second allows to drag the scene. Reviewed-by: bnilsen --- demos/chip/view.cpp | 54 +++++++++++++++++++++++++++++++++++++++++++++++------ demos/chip/view.h | 32 +++++++++++++++++++++++++------ 2 files changed, 74 insertions(+), 12 deletions(-) diff --git a/demos/chip/view.cpp b/demos/chip/view.cpp index 7af3074..d6a641e 100644 --- a/demos/chip/view.cpp +++ b/demos/chip/view.cpp @@ -48,15 +48,29 @@ #include +void GraphicsView::wheelEvent(QWheelEvent *e) +{ + if (e->modifiers() & Qt::ControlModifier) { + if (e->delta() > 0) + view->zoomIn(6); + else + view->zoomOut(6); + e->accept(); + } else { + QGraphicsView::wheelEvent(e); + } +} + View::View(const QString &name, QWidget *parent) : QFrame(parent) { setFrameStyle(Sunken | StyledPanel); - graphicsView = new QGraphicsView; + graphicsView = new GraphicsView(this); graphicsView->setRenderHint(QPainter::Antialiasing, false); graphicsView->setDragMode(QGraphicsView::RubberBandDrag); graphicsView->setOptimizationFlags(QGraphicsView::DontSavePainterState); graphicsView->setViewportUpdateMode(QGraphicsView::SmartViewportUpdate); + graphicsView->setTransformationAnchor(QGraphicsView::AnchorUnderMouse); int size = style()->pixelMetric(QStyle::PM_ToolBarIconSize); QSize iconSize(size, size); @@ -111,6 +125,15 @@ View::View(const QString &name, QWidget *parent) // Label layout QHBoxLayout *labelLayout = new QHBoxLayout; label = new QLabel(name); + label2 = new QLabel(tr("Pointer Mode")); + selectModeButton = new QToolButton; + selectModeButton->setText(tr("Select")); + selectModeButton->setCheckable(true); + selectModeButton->setChecked(true); + dragModeButton = new QToolButton; + dragModeButton->setText(tr("Drag")); + dragModeButton->setCheckable(true); + dragModeButton->setChecked(false); antialiasButton = new QToolButton; antialiasButton->setText(tr("Antialiasing")); antialiasButton->setCheckable(true); @@ -126,8 +149,17 @@ View::View(const QString &name, QWidget *parent) printButton = new QToolButton; printButton->setIcon(QIcon(QPixmap(":/fileprint.png"))); + QButtonGroup *pointerModeGroup = new QButtonGroup; + pointerModeGroup->setExclusive(true); + pointerModeGroup->addButton(selectModeButton); + pointerModeGroup->addButton(dragModeButton); + labelLayout->addWidget(label); labelLayout->addStretch(); + labelLayout->addWidget(label2); + labelLayout->addWidget(selectModeButton); + labelLayout->addWidget(dragModeButton); + labelLayout->addStretch(); labelLayout->addWidget(antialiasButton); labelLayout->addWidget(openGlButton); labelLayout->addWidget(printButton); @@ -145,6 +177,8 @@ View::View(const QString &name, QWidget *parent) connect(rotateSlider, SIGNAL(valueChanged(int)), this, SLOT(setupMatrix())); connect(graphicsView->verticalScrollBar(), SIGNAL(valueChanged(int)), this, SLOT(setResetButtonEnabled())); connect(graphicsView->horizontalScrollBar(), SIGNAL(valueChanged(int)), this, SLOT(setResetButtonEnabled())); + connect(selectModeButton, SIGNAL(toggled(bool)), this, SLOT(togglePointerMode())); + connect(dragModeButton, SIGNAL(toggled(bool)), this, SLOT(togglePointerMode())); connect(antialiasButton, SIGNAL(toggled(bool)), this, SLOT(toggleAntialiasing())); connect(openGlButton, SIGNAL(toggled(bool)), this, SLOT(toggleOpenGL())); connect(rotateLeftIcon, SIGNAL(clicked()), this, SLOT(rotateLeft())); @@ -158,7 +192,7 @@ View::View(const QString &name, QWidget *parent) QGraphicsView *View::view() const { - return graphicsView; + return static_cast(graphicsView); } void View::resetView() @@ -188,6 +222,14 @@ void View::setupMatrix() setResetButtonEnabled(); } +void View::togglePointerMode() +{ + graphicsView->setDragMode(selectModeButton->isChecked() + ? QGraphicsView::RubberBandDrag + : QGraphicsView::ScrollHandDrag); + graphicsView->setInteractive(selectModeButton->isChecked()); +} + void View::toggleOpenGL() { #ifndef QT_NO_OPENGL @@ -212,14 +254,14 @@ void View::print() #endif } -void View::zoomIn() +void View::zoomIn(int level) { - zoomSlider->setValue(zoomSlider->value() + 1); + zoomSlider->setValue(zoomSlider->value() + level); } -void View::zoomOut() +void View::zoomOut(int level) { - zoomSlider->setValue(zoomSlider->value() - 1); + zoomSlider->setValue(zoomSlider->value() - level); } void View::rotateLeft() diff --git a/demos/chip/view.h b/demos/chip/view.h index 8047b8b..67c7675 100644 --- a/demos/chip/view.h +++ b/demos/chip/view.h @@ -43,12 +43,27 @@ #define VIEW_H #include +#include -QT_FORWARD_DECLARE_CLASS(QGraphicsView) QT_FORWARD_DECLARE_CLASS(QLabel) QT_FORWARD_DECLARE_CLASS(QSlider) QT_FORWARD_DECLARE_CLASS(QToolButton) +class View; + +class GraphicsView : public QGraphicsView +{ + Q_OBJECT +public: + GraphicsView(View *v) : QGraphicsView(), view(v) { } + +protected: + void wheelEvent(QWheelEvent *); + +private: + View *view; +}; + class View : public QFrame { Q_OBJECT @@ -57,22 +72,27 @@ public: QGraphicsView *view() const; +public slots: + void zoomIn(int level = 1); + void zoomOut(int level = 1); + private slots: void resetView(); void setResetButtonEnabled(); void setupMatrix(); + void togglePointerMode(); void toggleOpenGL(); void toggleAntialiasing(); void print(); - - void zoomIn(); - void zoomOut(); void rotateLeft(); void rotateRight(); - + private: - QGraphicsView *graphicsView; + GraphicsView *graphicsView; QLabel *label; + QLabel *label2; + QToolButton *selectModeButton; + QToolButton *dragModeButton; QToolButton *openGlButton; QToolButton *antialiasButton; QToolButton *printButton; -- cgit v0.12 From d96aa02b46f4ff999d4353d8cd7a56ac426e58e0 Mon Sep 17 00:00:00 2001 From: Yoann Lopes Date: Mon, 15 Nov 2010 15:36:40 +0100 Subject: Change in QGraphicsView documentation. Reviewed-by: bnilsen --- src/gui/graphicsview/qgraphicsview.cpp | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/src/gui/graphicsview/qgraphicsview.cpp b/src/gui/graphicsview/qgraphicsview.cpp index 0d39bb5..73f1493 100644 --- a/src/gui/graphicsview/qgraphicsview.cpp +++ b/src/gui/graphicsview/qgraphicsview.cpp @@ -80,9 +80,7 @@ static const int QGRAPHICSVIEW_PREALLOC_STYLE_OPTIONS = 503; // largest prime < yourself, you can call setSceneRect(). This will adjust the scroll bars' ranges appropriately. Note that although the scene supports a virtually unlimited size, the range of the scroll bars will never exceed the range of - an integer (INT_MIN, INT_MAX). When the scene is larger than the scroll - bars' values, you can choose to use translate() to navigate the scene - instead. + an integer (INT_MIN, INT_MAX). QGraphicsView visualizes the scene by calling render(). By default, the items are drawn onto the viewport by using a regular QPainter, and using @@ -101,7 +99,8 @@ static const int QGRAPHICSVIEW_PREALLOC_STYLE_OPTIONS = 503; // largest prime < convenience functions rotate(), scale(), translate() or shear(). The most two common transformations are scaling, which is used to implement zooming, and rotation. QGraphicsView keeps the center of the view fixed - during a transformation. + during a transformation. Because of the scene alignment (setAligment()), + translating the view will have no visual impact. You can interact with the items on the scene by using the mouse and keyboard. QGraphicsView translates the mouse and key events into \e scene -- cgit v0.12 From 5803bf9c714bbfc9ecdee8b4fa8ebf87d9bfc4f4 Mon Sep 17 00:00:00 2001 From: Fabien Freling Date: Mon, 15 Nov 2010 16:19:02 +0100 Subject: Avoid the flushing of widgets that shouldn't show on screen. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This is mostly fixing errors appearing on the command-line when using native dialogs. Task-number: QTBUG-15169 Reviewed-by: Samuel Rødal --- src/gui/painting/qwindowsurface_raster.cpp | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/gui/painting/qwindowsurface_raster.cpp b/src/gui/painting/qwindowsurface_raster.cpp index 217723f..ae73d7d 100644 --- a/src/gui/painting/qwindowsurface_raster.cpp +++ b/src/gui/painting/qwindowsurface_raster.cpp @@ -251,6 +251,11 @@ void QRasterWindowSurface::flush(QWidget *widget, const QRegion &rgn, const QPoi #ifdef Q_WS_MAC + // This is mainly done for native components like native "open file" dialog. + if (widget->testAttribute(Qt::WA_DontShowOnScreen)) { + return; + } + #ifdef QT_MAC_USE_COCOA // Unified toolbar hack. QMainWindow* mWindow = qobject_cast(widget->window()); -- cgit v0.12