From c8e08e5c74fbdae8a60bdd9b08966ea7fc728845 Mon Sep 17 00:00:00 2001 From: "Bradley T. Hughes" Date: Wed, 14 Apr 2010 03:06:22 +0200 Subject: Prevent accelerators from firing on X11 and QWS during a drag Drag-and-drop has always been modal, and already blocks key events. It should block all application accelerators as well, to avoid unexpected things like being unable to cancel the drag-and-drop (as mentioned in the task), or by being able to unexpectedly recurse the drag-and-drop event loop (by, for example, opening a file dialog). Task-number: QTBUG-9786 Reviewed-by: TrustMe --- src/gui/kernel/qdnd_qws.cpp | 4 ++++ src/gui/kernel/qdnd_x11.cpp | 6 ++++++ 2 files changed, 10 insertions(+) diff --git a/src/gui/kernel/qdnd_qws.cpp b/src/gui/kernel/qdnd_qws.cpp index e47de00..7e5afc7 100644 --- a/src/gui/kernel/qdnd_qws.cpp +++ b/src/gui/kernel/qdnd_qws.cpp @@ -192,6 +192,10 @@ bool QDragManager::eventFilter(QObject *o, QEvent *e) return false; switch(e->type()) { + case QEvent::ShortcutOverride: + // prevent accelerators from firing while dragging + e->accept(); + return true; case QEvent::KeyPress: case QEvent::KeyRelease: diff --git a/src/gui/kernel/qdnd_x11.cpp b/src/gui/kernel/qdnd_x11.cpp index 0a05d8e..2b12317 100644 --- a/src/gui/kernel/qdnd_x11.cpp +++ b/src/gui/kernel/qdnd_x11.cpp @@ -1299,6 +1299,12 @@ bool QDragManager::eventFilter(QObject * o, QEvent * e) return true; } + if (e->type() == QEvent::ShortcutOverride) { + // prevent accelerators from firing while dragging + e->accept(); + return true; + } + if (e->type() == QEvent::KeyPress || e->type() == QEvent::KeyRelease) { QKeyEvent *ke = ((QKeyEvent*)e); if (ke->key() == Qt::Key_Escape && e->type() == QEvent::KeyPress) { -- cgit v0.12 From b2e7709b55559ca20f627dff443b517421892779 Mon Sep 17 00:00:00 2001 From: Martin Smith Date: Mon, 3 May 2010 13:23:47 +0200 Subject: qdoc: Added more API topics. Are these important? --- tools/qdoc3/htmlgenerator.cpp | 2 ++ tools/qdoc3/node.cpp | 2 +- tools/qdoc3/test/qt-html-templates.qdocconf | 11 ++++++++--- 3 files changed, 11 insertions(+), 4 deletions(-) diff --git a/tools/qdoc3/htmlgenerator.cpp b/tools/qdoc3/htmlgenerator.cpp index a0cd560..40145ff 100644 --- a/tools/qdoc3/htmlgenerator.cpp +++ b/tools/qdoc3/htmlgenerator.cpp @@ -1739,6 +1739,8 @@ void HtmlGenerator::generateBreadCrumbs(const QString& title, } } else if (node->subType() == Node::QmlClass) { + out() << "
  • name() << "\">" << title + << "
  • "; } else if (node->subType() == Node::Example) { out() << "
  • All Examples
  • "; diff --git a/tools/qdoc3/node.cpp b/tools/qdoc3/node.cpp index a2bd948..4ba3a32 100644 --- a/tools/qdoc3/node.cpp +++ b/tools/qdoc3/node.cpp @@ -1289,7 +1289,7 @@ QmlClassNode::QmlClassNode(InnerNode *parent, const ClassNode* cn) : FakeNode(parent, name, QmlClass), cnode(cn) { - setTitle((qmlOnly ? "" : "QML ") + name + " Element Reference"); + setTitle((qmlOnly ? "" : "QML ") + name + " Element"); } /*! diff --git a/tools/qdoc3/test/qt-html-templates.qdocconf b/tools/qdoc3/test/qt-html-templates.qdocconf index 85a29c2..0651176 100644 --- a/tools/qdoc3/test/qt-html-templates.qdocconf +++ b/tools/qdoc3/test/qt-html-templates.qdocconf @@ -58,10 +58,15 @@ HTML.postheader = "
    \n" \ "
    \n" \ " \n" \ "
    \n" \ "
    \n" \ -- cgit v0.12 From 5280657f5e6adecbaf374b6dd027a753af854771 Mon Sep 17 00:00:00 2001 From: Thiago Macieira Date: Mon, 3 May 2010 13:20:31 +0200 Subject: Unix configure: fix sed pattern extracting C and C++ flags from mkspec Reviewed-By: ossi --- configure | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/configure b/configure index 6763969..47eec92 100755 --- a/configure +++ b/configure @@ -3097,8 +3097,8 @@ fi # auto-detect support for separate debug info in objcopy if [ "$CFG_SEPARATE_DEBUG_INFO" != "no" ] && [ "$CFG_SHARED" = "yes" ]; then - TEST_COMPILER_CFLAGS=`getQMakeConf "$XQMAKESPEC" | sed -n -e 's%QMAKE_CFLAGS[^_].*=%%p' | tr '\n' ' '` - TEST_COMPILER_CXXFLAGS=`getQMakeConf "$XQMAKESPEC" | sed -n -e 's%QMAKE_CXXFLAGS[^_].*=%%p' | tr '\n' ' '` + TEST_COMPILER_CFLAGS=`getQMakeConf "$XQMAKESPEC" | sed -n -e 's%QMAKE_CFLAGS[^_=]*[+*]*=%%p' | tr '\n' ' '` + TEST_COMPILER_CXXFLAGS=`getQMakeConf "$XQMAKESPEC" | sed -n -e 's%QMAKE_CXXFLAGS[^_=]*[+*]*=%%p' | tr '\n' ' '` TEST_OBJCOPY=`getQMakeConf "$XQMAKESPEC" | grep "^QMAKE_OBJCOPY" | sed "s%.* *= *\(.*\)$%\1%" | tail -1` COMPILER_WITH_FLAGS="$TEST_COMPILER $TEST_COMPILER_CXXFLAGS" COMPILER_WITH_FLAGS=`echo "$COMPILER_WITH_FLAGS" | sed -e "s%\\$\\$QMAKE_CFLAGS%$TEST_COMPILER_CFLAGS%g"` -- cgit v0.12 From 56a0c1d1e2868aa1bba421f16e4f917373f574ff Mon Sep 17 00:00:00 2001 From: Thiago Macieira Date: Mon, 3 May 2010 13:21:00 +0200 Subject: Don't quote $COMPILER because it may contain flags Reviewed-By: ossi --- config.tests/unix/bsymbolic_functions.test | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/config.tests/unix/bsymbolic_functions.test b/config.tests/unix/bsymbolic_functions.test index 52fdb32..6c34895 100755 --- a/config.tests/unix/bsymbolic_functions.test +++ b/config.tests/unix/bsymbolic_functions.test @@ -4,11 +4,12 @@ BSYMBOLIC_FUNCTIONS_SUPPORT=no COMPILER=$1 VERBOSE=$2 + cat >>bsymbolic_functions.c << EOF int main() { return 0; } EOF -"$COMPILER" -o libtest.so -shared -Wl,-Bsymbolic-functions -fPIC bsymbolic_functions.c >/dev/null 2>&1 && BSYMBOLIC_FUNCTIONS_SUPPORT=yes +$COMPILER -o libtest.so -shared -Wl,-Bsymbolic-functions -fPIC bsymbolic_functions.c >/dev/null 2>&1 && BSYMBOLIC_FUNCTIONS_SUPPORT=yes rm -f bsymbolic_functions.c libtest.so # done -- cgit v0.12 From 3d852917187e29892529ab51d24c1a1177068a88 Mon Sep 17 00:00:00 2001 From: Thiago Macieira Date: Mon, 3 May 2010 13:22:09 +0200 Subject: QMap: make sure we never access forward and backward through typed Node structs See the comment in the file why. Reviewed-By: Olivier Goffart --- src/corelib/tools/qmap.h | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/src/corelib/tools/qmap.h b/src/corelib/tools/qmap.h index df0ae46..5696ba6 100644 --- a/src/corelib/tools/qmap.h +++ b/src/corelib/tools/qmap.h @@ -125,6 +125,10 @@ template struct QMapNode { Key key; T value; + +private: + // never access these members through this structure. + // see below QMapData::Node *backward; QMapData::Node *forward[1]; }; @@ -134,6 +138,22 @@ struct QMapPayloadNode { Key key; T value; + +private: + // QMap::e is a pointer to QMapData::Node, which matches the member + // below. However, the memory allocation node in QMapData::node_create + // allocates sizeof(QMapPayloNode) and incorrectly calculates the offset + // of 'backward' below. If the alignment of QMapPayloadNode is larger + // than the alignment of a pointer, the 'backward' member is aligned to + // the end of this structure, not to 'value' above, and will occupy the + // tail-padding area. + // + // e.g., on a 32-bit archictecture with Key = int and + // sizeof(T) = alignof(T) = 8 + // 0 4 8 12 16 20 24 byte + // | key | PAD | value |backward| PAD | correct layout + // | key | PAD | value | |backward| how it's actually used + // |<----- value of QMap::payload() = 20 ----->| QMapData::Node *backward; }; -- cgit v0.12 From e4c60e6b8d111c6214d8ee47b8c2bb8b9f8fcfe2 Mon Sep 17 00:00:00 2001 From: Denis Dzyubenko Date: Wed, 21 Apr 2010 14:56:40 +0200 Subject: Support updating system locale data on Symbian Subscribing to the locale change notification to be able to update the system locale whenever the user changes the current system locale. Task-number: QTBUG-4870 Reviewed-by: Thomas Zander Reviewed-by: Jason Barron --- mkspecs/common/symbian/symbian.conf | 2 +- src/corelib/kernel/qcoreapplication.cpp | 13 ++++++ src/corelib/kernel/qcoreapplication_p.h | 7 ++++ src/corelib/kernel/qeventdispatcher_symbian.cpp | 2 + src/corelib/kernel/qeventdispatcher_symbian_p.h | 1 + src/corelib/tools/qlocale.cpp | 12 ++++++ src/corelib/tools/qlocale_p.h | 18 +++++++++ src/corelib/tools/qlocale_symbian.cpp | 53 +++++++++++++++++++++++-- src/gui/kernel/qapplication.cpp | 4 ++ 9 files changed, 107 insertions(+), 5 deletions(-) diff --git a/mkspecs/common/symbian/symbian.conf b/mkspecs/common/symbian/symbian.conf index 0bd0bf2..89034ca 100644 --- a/mkspecs/common/symbian/symbian.conf +++ b/mkspecs/common/symbian/symbian.conf @@ -66,7 +66,7 @@ QMAKE_LINK_OBJECT_MAX = QMAKE_LINK_OBJECT_SCRIPT= QMAKE_LIBS = -llibc -llibm -leuser -llibdl -QMAKE_LIBS_CORE = $$QMAKE_LIBS -lefsrv -lhal +QMAKE_LIBS_CORE = $$QMAKE_LIBS -lefsrv -lhal -lbafl QMAKE_LIBS_GUI = $$QMAKE_LIBS_CORE -lfbscli -lbitgdi -lgdi -lws32 -lapgrfx -lcone -leikcore -lmediaclientaudio -leikcoctl -leiksrv -lapparc -lcentralrepository QMAKE_LIBS_NETWORK = QMAKE_LIBS_EGL = -llibEGL diff --git a/src/corelib/kernel/qcoreapplication.cpp b/src/corelib/kernel/qcoreapplication.cpp index bf2e2e4..f44fe99 100644 --- a/src/corelib/kernel/qcoreapplication.cpp +++ b/src/corelib/kernel/qcoreapplication.cpp @@ -63,6 +63,7 @@ #include #include #include +#include #ifdef Q_OS_SYMBIAN # include @@ -521,6 +522,9 @@ QCoreApplication::QCoreApplication(int &argc, char **argv) QFactoryLoader::refreshAll(); #endif +#if defined(Q_OS_SYMBIAN) && !defined(QT_NO_SYSTEMLOCALE) + d_func()->symbianInit(); +#endif } // ### move to QCoreApplicationPrivate constructor? @@ -597,6 +601,15 @@ void QCoreApplication::init() qt_startup_hook(); } +#if defined(Q_OS_SYMBIAN) && !defined(QT_NO_SYSTEMLOCALE) +void QCoreApplicationPrivate::symbianInit() +{ + if (!environmentChangeNotifier) + environmentChangeNotifier.reset(new QEnvironmentChangeNotifier); +} +#endif + + /*! Destroys the QCoreApplication object. */ diff --git a/src/corelib/kernel/qcoreapplication_p.h b/src/corelib/kernel/qcoreapplication_p.h index 77188d3..e066137 100644 --- a/src/corelib/kernel/qcoreapplication_p.h +++ b/src/corelib/kernel/qcoreapplication_p.h @@ -65,6 +65,9 @@ QT_BEGIN_NAMESPACE typedef QList QTranslatorList; +#if defined(Q_OS_SYMBIAN) && !defined(QT_NO_SYSTEMLOCALE) +class QEnvironmentChangeNotifier; +#endif class QAbstractEventDispatcher; class Q_CORE_EXPORT QCoreApplicationPrivate : public QObjectPrivate @@ -113,6 +116,10 @@ public: bool aboutToQuitEmitted; QString cachedApplicationDirPath; QString cachedApplicationFilePath; +#if defined(Q_OS_SYMBIAN) && !defined(QT_NO_SYSTEMLOCALE) + QScopedPointer environmentChangeNotifier; + void symbianInit(); +#endif static bool isTranslatorInstalled(QTranslator *translator); diff --git a/src/corelib/kernel/qeventdispatcher_symbian.cpp b/src/corelib/kernel/qeventdispatcher_symbian.cpp index a6d486e..687a6d9 100644 --- a/src/corelib/kernel/qeventdispatcher_symbian.cpp +++ b/src/corelib/kernel/qeventdispatcher_symbian.cpp @@ -1105,3 +1105,5 @@ void CQtActiveScheduler::Error(TInt aError) const } QT_END_NAMESPACE + +#include "moc_qeventdispatcher_symbian_p.cpp" diff --git a/src/corelib/kernel/qeventdispatcher_symbian_p.h b/src/corelib/kernel/qeventdispatcher_symbian_p.h index 05758ca..bc42753 100644 --- a/src/corelib/kernel/qeventdispatcher_symbian_p.h +++ b/src/corelib/kernel/qeventdispatcher_symbian_p.h @@ -221,6 +221,7 @@ public: // from CActiveScheduler class Q_CORE_EXPORT QEventDispatcherSymbian : public QAbstractEventDispatcher { + Q_OBJECT Q_DECLARE_PRIVATE(QAbstractEventDispatcher) public: diff --git a/src/corelib/tools/qlocale.cpp b/src/corelib/tools/qlocale.cpp index c3f6783..20c2e27 100644 --- a/src/corelib/tools/qlocale.cpp +++ b/src/corelib/tools/qlocale.cpp @@ -129,6 +129,11 @@ inline bool isascii(int c) } #endif +#if defined(Q_OS_SYMBIAN) +void qt_symbianUpdateSystemPrivate(); +void qt_symbianInitSystemLocale(); +#endif + /****************************************************************************** ** Helpers for accessing Qt locale database */ @@ -1407,6 +1412,9 @@ static const QSystemLocale *systemLocale() { if (_systemLocale) return _systemLocale; +#if defined(Q_OS_SYMBIAN) + qt_symbianInitSystemLocale(); +#endif return QSystemLocale_globalSystemLocale(); } @@ -1417,6 +1425,10 @@ void QLocalePrivate::updateSystemPrivate() system_lp = globalLocalePrivate(); *system_lp = *sys_locale->fallbackLocale().d(); +#if defined(Q_OS_SYMBIAN) + qt_symbianUpdateSystemPrivate(); +#endif + QVariant res = sys_locale->query(QSystemLocale::LanguageId, QVariant()); if (!res.isNull()) system_lp->m_language_id = res.toInt(); diff --git a/src/corelib/tools/qlocale_p.h b/src/corelib/tools/qlocale_p.h index ecf79e9..6205745 100644 --- a/src/corelib/tools/qlocale_p.h +++ b/src/corelib/tools/qlocale_p.h @@ -58,6 +58,10 @@ #include "qlocale.h" +#if defined(Q_OS_SYMBIAN) && !defined(QT_NO_SYSTEMLOCALE) +class CEnvironmentChangeNotifier; +#endif + QT_BEGIN_NAMESPACE struct Q_CORE_EXPORT QLocalePrivate @@ -201,6 +205,20 @@ inline char QLocalePrivate::digitToCLocale(const QChar &in) const return 0; } +#if defined(Q_OS_SYMBIAN) && !defined(QT_NO_SYSTEMLOCALE) +class QEnvironmentChangeNotifier +{ +public: + QEnvironmentChangeNotifier(); + ~QEnvironmentChangeNotifier(); + + static TInt localeChanged(TAny *data); + +private: + CEnvironmentChangeNotifier *iChangeNotifier; +}; +#endif + QT_END_NAMESPACE #endif // QLOCALE_P_H diff --git a/src/corelib/tools/qlocale_symbian.cpp b/src/corelib/tools/qlocale_symbian.cpp index 01f56cc..6e36dcd 100644 --- a/src/corelib/tools/qlocale_symbian.cpp +++ b/src/corelib/tools/qlocale_symbian.cpp @@ -46,8 +46,14 @@ #include #include +#include +#include +#include +#include #include "private/qcore_symbian_p.h" - +#include "private/qcoreapplication_p.h" +#include "private/qlocale_p.h" +#include QT_BEGIN_NAMESPACE @@ -771,13 +777,18 @@ static QLocale::MeasurementSystem symbianMeasurementSystem() return QLocale::MetricSystem; } -QLocale QSystemLocale::fallbackLocale() const +void qt_symbianUpdateSystemPrivate() { // load system data before query calls + _s60Locale.LoadSystemSettings(); +} + +void qt_symbianInitSystemLocale() +{ static QBasicAtomicInt initDone = Q_BASIC_ATOMIC_INITIALIZER(0); + if (initDone == 2) + return; if (initDone.testAndSetRelaxed(0, 1)) { - _s60Locale.LoadSystemSettings(); - // Initialize platform version dependent function pointers ptrTimeFormatL = reinterpret_cast (qt_resolveS60PluginFunc(S60Plugin_TimeFormatL)); @@ -801,7 +812,10 @@ QLocale QSystemLocale::fallbackLocale() const } while(initDone != 2) QThread::yieldCurrentThread(); +} +QLocale QSystemLocale::fallbackLocale() const +{ TLanguage lang = User::Language(); QString locale = QLatin1String(qt_symbianLocaleName(lang)); return QLocale(locale); @@ -884,4 +898,35 @@ QVariant QSystemLocale::query(QueryType type, QVariant in = QVariant()) const return QVariant(); } +#if !defined(QT_NO_SYSTEMLOCALE) +QEnvironmentChangeNotifier::QEnvironmentChangeNotifier() +{ + // Create the change notifier and install the callback function + const TCallBack callback(&QEnvironmentChangeNotifier::localeChanged, this); + QT_TRAP_THROWING(iChangeNotifier = CEnvironmentChangeNotifier::NewL(CActive::EPriorityStandard, callback)); + iChangeNotifier->Start(); +} + +TInt QEnvironmentChangeNotifier::localeChanged(TAny *data) +{ + QEnvironmentChangeNotifier *that = reinterpret_cast(data); + + TInt flag = that->iChangeNotifier->Change(); + if (flag & EChangesLocale) { + static bool first = true; + if (!first) { // skip the first notification on app startup + QT_TRYCATCH_LEAVING(QLocalePrivate::updateSystemPrivate()); + QT_TRYCATCH_LEAVING(QCoreApplication::postEvent(qApp, new QEvent(QEvent::LocaleChange))); + } + first = false; + } + return KErrNone; +} + +QEnvironmentChangeNotifier::~QEnvironmentChangeNotifier() +{ + delete iChangeNotifier; +} +#endif + QT_END_NAMESPACE diff --git a/src/gui/kernel/qapplication.cpp b/src/gui/kernel/qapplication.cpp index ec635d4..bc58c76 100644 --- a/src/gui/kernel/qapplication.cpp +++ b/src/gui/kernel/qapplication.cpp @@ -788,6 +788,10 @@ void QApplicationPrivate::construct( qt_gui_eval_init(application_type); #endif +#if defined(Q_OS_SYMBIAN) && !defined(QT_NO_SYSTEMLOCALE) + symbianInit(); +#endif + #ifndef QT_NO_LIBRARY if(load_testability) { QLibrary testLib(QLatin1String("qttestability")); -- cgit v0.12 From fe59ef0bf3c8d0ae92c15cd69839df2232a60936 Mon Sep 17 00:00:00 2001 From: Denis Dzyubenko Date: Wed, 21 Apr 2010 11:47:31 +0200 Subject: Propagate LocaleChange event from application to widgets. The LocaleChange event will be sent to the QApplication object and then propagated to all widgets down the hierarchy starting with toplevels. Reviewed-by: Thomas Zander --- src/gui/kernel/qapplication.cpp | 13 +++++++++++++ src/gui/kernel/qapplication_win.cpp | 2 ++ 2 files changed, 15 insertions(+) diff --git a/src/gui/kernel/qapplication.cpp b/src/gui/kernel/qapplication.cpp index bc58c76..7b62de1 100644 --- a/src/gui/kernel/qapplication.cpp +++ b/src/gui/kernel/qapplication.cpp @@ -2368,6 +2368,19 @@ bool QApplication::event(QEvent *e) if (!(w->windowType() == Qt::Desktop)) postEvent(w, new QEvent(QEvent::LanguageChange)); } +#ifndef Q_OS_WIN + } else if (e->type() == QEvent::LocaleChange) { + // on Windows the event propagation is taken care by the + // WM_SETTINGCHANGE event handler. + QWidgetList list = topLevelWidgets(); + for (int i = 0; i < list.size(); ++i) { + QWidget *w = list.at(i); + if (!(w->windowType() == Qt::Desktop)) { + if (!w->testAttribute(Qt::WA_SetLocale)) + w->d_func()->setLocale_helper(QLocale(), true); + } + } +#endif } else if (e->type() == QEvent::Timer) { QTimerEvent *te = static_cast(e); Q_ASSERT(te != 0); diff --git a/src/gui/kernel/qapplication_win.cpp b/src/gui/kernel/qapplication_win.cpp index fb2837e..50b9759 100644 --- a/src/gui/kernel/qapplication_win.cpp +++ b/src/gui/kernel/qapplication_win.cpp @@ -1936,6 +1936,8 @@ extern "C" LRESULT QT_WIN_CALLBACK QtWndProc(HWND hwnd, UINT message, WPARAM wPa QLocalePrivate::updateSystemPrivate(); if (!widget->testAttribute(Qt::WA_SetLocale)) widget->dptr()->setLocale_helper(QLocale(), true); + QEvent e(QEvent::LocaleChange); + QApplication::sendEvent(qApp, &e); } } else if (msg.wParam == SPI_SETICONTITLELOGFONT) { -- cgit v0.12 From 7bcc52d4c1905a5d1777c4c43427e359948959fe Mon Sep 17 00:00:00 2001 From: Denis Dzyubenko Date: Mon, 3 May 2010 16:03:11 +0200 Subject: Fixes a crash in QGestureManager when unregistering recognizers. Task-number: QTBUG-9801 Reviewed-by: Thomas Zander --- src/gui/kernel/qgesturemanager.cpp | 20 +++++----- tests/auto/gestures/tst_gestures.cpp | 71 ++++++++++++++++++++++++++++++++++++ 2 files changed, 81 insertions(+), 10 deletions(-) diff --git a/src/gui/kernel/qgesturemanager.cpp b/src/gui/kernel/qgesturemanager.cpp index aa6720e..a806629 100644 --- a/src/gui/kernel/qgesturemanager.cpp +++ b/src/gui/kernel/qgesturemanager.cpp @@ -132,20 +132,20 @@ void QGestureManager::unregisterGestureRecognizer(Qt::GestureType type) QGestureRecognizer *recognizer = m_gestureToRecognizer.value(g); if (list.contains(recognizer)) { m_deletedRecognizers.insert(g, recognizer); - m_gestureToRecognizer.remove(g); } } - foreach (QGestureRecognizer *recognizer, list) { - QList obsoleteGestures; - QMap >::Iterator iter = m_objectGestures.begin(); - while (iter != m_objectGestures.end()) { - ObjectGesture objectGesture = iter.key(); - if (objectGesture.gesture == type) - obsoleteGestures << iter.value(); - ++iter; + QMap >::const_iterator iter = m_objectGestures.begin(); + while (iter != m_objectGestures.end()) { + ObjectGesture objectGesture = iter.key(); + if (objectGesture.gesture == type) { + foreach (QGesture *g, iter.value()) { + QGestureRecognizer *recognizer = m_gestureToRecognizer.value(g); + m_gestureToRecognizer.remove(g); + m_obsoleteGestures[recognizer].append(g); + } } - m_obsoleteGestures.insert(recognizer, obsoleteGestures); + ++iter; } } diff --git a/tests/auto/gestures/tst_gestures.cpp b/tests/auto/gestures/tst_gestures.cpp index f8ecca3..dfadf48 100644 --- a/tests/auto/gestures/tst_gestures.cpp +++ b/tests/auto/gestures/tst_gestures.cpp @@ -50,6 +50,7 @@ #include #include #include +#include #include @@ -355,6 +356,7 @@ private slots: void deleteGestureTargetItem(); void viewportCoordinates(); void partialGesturePropagation(); + void testQGestureRecognizerCleanup(); }; tst_Gestures::tst_Gestures() @@ -1949,5 +1951,74 @@ void tst_Gestures::partialGesturePropagation() QCOMPARE(item4->gestureEventsReceived, 0); } +class WinNativePan : public QPanGesture { +public: + WinNativePan() {} +}; + +class Pan : public QPanGesture { +public: + Pan() {} +}; + +class CustomPan : public QPanGesture { +public: + CustomPan() {} +}; + +// Recognizer for active gesture triggers on mouse press +class PanRecognizer : public QGestureRecognizer { +public: + enum PanType { Platform, Default, Custom }; + + PanRecognizer(int id) : m_id(id) {} + QGesture *create(QObject *) { + switch(m_id) { + case Platform: return new WinNativePan(); + case Default: return new Pan(); + default: return new CustomPan(); + } + } + + Result recognize(QGesture *, QObject *, QEvent *) { return QGestureRecognizer::Ignore; } + + const int m_id; +}; + +void tst_Gestures::testQGestureRecognizerCleanup() +{ + // Clean first the current recognizers in QGManager + QGestureRecognizer::unregisterRecognizer(Qt::PanGesture); + + // v-- Qt singleton QGManager initialization + + // Mimic QGestureManager: register both default and "platform" recognizers + // (this is done in windows when QT_NO_NATIVE_GESTURES is not defined) + PanRecognizer *def = new PanRecognizer(PanRecognizer::Default); + QGestureRecognizer::registerRecognizer(def); + PanRecognizer *plt = new PanRecognizer(PanRecognizer::Platform); + QGestureRecognizer::registerRecognizer(plt); + qDebug () << "register: default =" << def << "; platform =" << plt; + + // ^-- Qt singleton QGManager initialization + + // Here, application code would start + + // Create QGV (has a QAScrollArea, which uses Qt::PanGesture) + QMainWindow *w = new QMainWindow; + QGraphicsView *v = new QGraphicsView(); + w->setCentralWidget(v); + + // Unregister Qt recognizers + QGestureRecognizer::unregisterRecognizer(Qt::PanGesture); + + // Register a custom Pan recognizer + //QGestureRecognizer::registerRecognizer(new PanRecognizer(PanRecognizer::Custom)); + + w->show(); + QTest::qWaitForWindowShown(w); + delete w; +} + QTEST_MAIN(tst_Gestures) #include "tst_gestures.moc" -- cgit v0.12 From 7b3092423dc4b6c66aa34c483e6ede2e22747159 Mon Sep 17 00:00:00 2001 From: Jens Bache-Wiig Date: Mon, 3 May 2010 20:43:30 +0200 Subject: Increase tooltip margin for cleanlooks+gtk While gtkstyle should really query the width/height individually, this will help visually for now. The current 1-pixel margin look quite ugly in the Qt Creator editor at the moment. Reviewed-by: mae --- src/gui/styles/qcleanlooksstyle.cpp | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/gui/styles/qcleanlooksstyle.cpp b/src/gui/styles/qcleanlooksstyle.cpp index 0f39b23..ba24d97 100644 --- a/src/gui/styles/qcleanlooksstyle.cpp +++ b/src/gui/styles/qcleanlooksstyle.cpp @@ -3714,6 +3714,9 @@ int QCleanlooksStyle::pixelMetric(PixelMetric metric, const QStyleOption *option { int ret = -1; switch (metric) { + case PM_ToolTipLabelFrameWidth: + ret = 2; + break; case PM_ButtonDefaultIndicator: ret = 0; break; -- cgit v0.12 From 3d745d7ded2ed8d52a8c6d9f7113bd6a61e13647 Mon Sep 17 00:00:00 2001 From: Ritt Konstantin Date: Mon, 3 May 2010 23:53:23 +0400 Subject: add static QChar::is(High|Low)Surrogate methods to avoid recoding of character this also adds QChar::requiresSurrogates() static member supposed to save from common mistake like `ucs4 > 0x10000` Merge-request: 606 Reviewed-by: Thiago Macieira --- src/corelib/tools/qchar.cpp | 31 +++++++++++++++++++++++++++++-- src/corelib/tools/qchar.h | 9 +++++++++ 2 files changed, 38 insertions(+), 2 deletions(-) diff --git a/src/corelib/tools/qchar.cpp b/src/corelib/tools/qchar.cpp index 67ea00d..2f09b0e 100644 --- a/src/corelib/tools/qchar.cpp +++ b/src/corelib/tools/qchar.cpp @@ -653,14 +653,41 @@ bool QChar::isSymbol() const \fn bool QChar::isHighSurrogate() const Returns true if the QChar is the high part of a utf16 surrogate - (ie. if its code point is between 0xd800 and 0xdbff). + (ie. if its code point is between 0xd800 and 0xdbff, inclusive). */ /*! \fn bool QChar::isLowSurrogate() const Returns true if the QChar is the low part of a utf16 surrogate - (ie. if its code point is between 0xdc00 and 0xdfff). + (ie. if its code point is between 0xdc00 and 0xdfff, inclusive). +*/ + +/*! + \fn static bool QChar::isHighSurrogate(uint ucs4) + \since 4.7 + + Returns true if the UCS-4-encoded character specified by \a ucs4 + is the high part of a utf16 surrogate + (ie. if its code point is between 0xd800 and 0xdbff, inclusive). +*/ + +/*! + \fn static bool QChar::isLowSurrogate(uint ucs4) + \since 4.7 + + Returns true if the UCS-4-encoded character specified by \a ucs4 + is the high part of a utf16 surrogate + (ie. if its code point is between 0xdc00 and 0xdfff, inclusive). +*/ + +/*! + \fn static bool QChar::requiresSurrogates(uint ucs4) + \since 4.7 + + Returns true if the UCS-4-encoded character specified by \a ucs4 + can be splited to the high and low parts of a utf16 surrogate + (ie. if its code point is greater than or equals to 0x10000). */ /*! diff --git a/src/corelib/tools/qchar.h b/src/corelib/tools/qchar.h index 1432c7f..205f911 100644 --- a/src/corelib/tools/qchar.h +++ b/src/corelib/tools/qchar.h @@ -285,6 +285,15 @@ public: inline void setCell(uchar cell); inline void setRow(uchar row); + static inline bool isHighSurrogate(uint ucs4) { + return ((ucs4 & 0xfffffc00) == 0xd800); + } + static inline bool isLowSurrogate(uint ucs4) { + return ((ucs4 & 0xfffffc00) == 0xdc00); + } + static inline bool requiresSurrogates(uint ucs4) { + return (ucs4 >= 0x10000); + } static inline uint surrogateToUcs4(ushort high, ushort low) { return (uint(high)<<10) + low - 0x35fdc00; } -- cgit v0.12