From 693e39f3b630afa44cd1bd8d942825922a5d59fe Mon Sep 17 00:00:00 2001 From: Jiang Jiang Date: Tue, 12 Jul 2011 09:31:07 +0200 Subject: Fix warning for uninitialized variable Reviewed-by: Eskil --- src/gui/text/qtextengine.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/gui/text/qtextengine.cpp b/src/gui/text/qtextengine.cpp index c900918..db50bdf 100644 --- a/src/gui/text/qtextengine.cpp +++ b/src/gui/text/qtextengine.cpp @@ -323,7 +323,7 @@ static QChar::Direction skipBoundryNeutrals(QScriptAnalysis *analysis, const ushort *unicode, int length, int &sor, int &eor, QBidiControl &control) { - QChar::Direction dir; + QChar::Direction dir = control.basicDirection(); int level = sor > 0 ? analysis[sor - 1].bidiLevel : control.level; while (sor < length) { dir = QChar::direction(unicode[sor]); -- cgit v0.12 From da0e1e101bb4c44c25b6523357fa81ad1b2d6539 Mon Sep 17 00:00:00 2001 From: Lars Knoll Date: Tue, 12 Jul 2011 10:22:33 +0200 Subject: Add QLocale::toUpper/Lower The toUpper/Lower() methods in QString should not be locale dependent, as this can lead to rather hard to find bugs in at least a turkish locale. Rather have explicit, locale dependend case conversions available in QLocale. Reviewed-by: Denis Dzyubenko --- src/corelib/tools/qlocale.cpp | 38 ++++++++++++++++++++++++++++++++++++++ src/corelib/tools/qlocale.h | 3 +++ src/corelib/tools/qstring.cpp | 30 ++++++++---------------------- tests/auto/qstring/tst_qstring.cpp | 20 ++++++++++++-------- 4 files changed, 61 insertions(+), 30 deletions(-) diff --git a/src/corelib/tools/qlocale.cpp b/src/corelib/tools/qlocale.cpp index d791529..8640c8b 100644 --- a/src/corelib/tools/qlocale.cpp +++ b/src/corelib/tools/qlocale.cpp @@ -88,6 +88,8 @@ Q_GLOBAL_STATIC(QLocalePrivate, globalLocalePrivate) #ifdef QT_USE_ICU extern bool qt_initIcu(const QString &localeName); +extern bool qt_u_strToUpper(const QString &str, QString *out, const QLocale &locale); +extern bool qt_u_strToLower(const QString &str, QString *out, const QLocale &locale); #endif /****************************************************************************** @@ -2180,6 +2182,42 @@ Qt::LayoutDirection QLocale::textDirection() const return Qt::LeftToRight; } +/*! + \since 4.8 + + Returns an uppercase copy of \a str. +*/ +QString QLocale::toUpper(const QString &str) const +{ +#ifdef QT_USE_ICU + { + QString result; + if (qt_u_strToUpper(str, &result, *this)) + return result; + // else fall through and use Qt's toUpper + } +#endif + return str.toUpper(); +} + +/*! + \since 4.8 + + Returns a lowercase copy of \a str. +*/ +QString QLocale::toLower(const QString &str) const +{ +#ifdef QT_USE_ICU + { + QString result; + if (qt_u_strToLower(str, &result, *this)) + return result; + // else fall through and use Qt's toUpper + } +#endif + return str.toLower(); +} + /*! \since 4.5 diff --git a/src/corelib/tools/qlocale.h b/src/corelib/tools/qlocale.h index 8a5d526..55dd55b 100644 --- a/src/corelib/tools/qlocale.h +++ b/src/corelib/tools/qlocale.h @@ -724,6 +724,9 @@ public: Qt::LayoutDirection textDirection() const; + QString toUpper(const QString &str) const; + QString toLower(const QString &str) const; + QString currencySymbol(CurrencySymbolFormat = CurrencySymbol) const; QString toCurrencyString(qlonglong, const QString &symbol = QString()) const; QString toCurrencyString(qulonglong, const QString &symbol = QString()) const; diff --git a/src/corelib/tools/qstring.cpp b/src/corelib/tools/qstring.cpp index ee45cfd..c303c00 100644 --- a/src/corelib/tools/qstring.cpp +++ b/src/corelib/tools/qstring.cpp @@ -109,8 +109,6 @@ static QHash *asciiCache = 0; #ifdef QT_USE_ICU // qlocale_icu.cpp extern bool qt_ucol_strcoll(const QChar *source, int sourceLength, const QChar *target, int targetLength, int *result); -extern bool qt_u_strToUpper(const QString &str, QString *out, const QLocale &locale); -extern bool qt_u_strToLower(const QString &str, QString *out, const QLocale &locale); #endif @@ -5012,7 +5010,10 @@ QString QString::rightJustified(int width, QChar fill, bool truncate) const \snippet doc/src/snippets/qstring/main.cpp 75 - \sa toUpper() + The case conversion will always happen in the 'C' locale. For locale dependent + case folding use QLocale::toLower() + + \sa toUpper(), QLocale::toLower() */ QString QString::toLower() const @@ -5023,15 +5024,6 @@ QString QString::toLower() const if (!d->size) return *this; -#ifdef QT_USE_ICU - { - QString result; - if (qt_u_strToLower(*this, &result, QLocale())) - return result; - // else fall through and use Qt's toUpper - } -#endif - const ushort *e = d->data + d->size; // this avoids one out of bounds check in the loop @@ -5112,7 +5104,10 @@ QString QString::toCaseFolded() const \snippet doc/src/snippets/qstring/main.cpp 81 - \sa toLower() + The case conversion will always happen in the 'C' locale. For locale dependent + case folding use QLocale::toUpper() + + \sa toLower(), QLocale::toLower() */ QString QString::toUpper() const @@ -5123,15 +5118,6 @@ QString QString::toUpper() const if (!d->size) return *this; -#ifdef QT_USE_ICU - { - QString result; - if (qt_u_strToUpper(*this, &result, QLocale())) - return result; - // else fall through and use Qt's toUpper - } -#endif - const ushort *e = d->data + d->size; // this avoids one out of bounds check in the loop diff --git a/tests/auto/qstring/tst_qstring.cpp b/tests/auto/qstring/tst_qstring.cpp index b26121c..214b2f3 100644 --- a/tests/auto/qstring/tst_qstring.cpp +++ b/tests/auto/qstring/tst_qstring.cpp @@ -5103,24 +5103,28 @@ void tst_QString::toUpperLower_icu() QLocale::setDefault(QLocale(QLocale::Turkish, QLocale::Turkey)); + QCOMPARE(s.toUpper(), QString::fromLatin1("I")); + QCOMPARE(s.toLower(), QString::fromLatin1("i")); + // turkish locale has a capital I with a dot (U+0130, utf8 c4b0) + QLocale l; - QCOMPARE(s.toUpper(), QString::fromUtf8("\xc4\xb0")); - QCOMPARE(QString::fromUtf8("\xc4\xb0").toLower(), s); + QCOMPARE(l.toUpper(s), QString::fromUtf8("\xc4\xb0")); + QCOMPARE(l.toLower(QString::fromUtf8("\xc4\xb0")), s); // nothing should happen here - QCOMPARE(s.toLower(), s); - QCOMPARE(QString::fromLatin1("I").toUpper(), QString::fromLatin1("I")); + QCOMPARE(l.toLower(s), s); + QCOMPARE(l.toUpper(QString::fromLatin1("I")), QString::fromLatin1("I")); // U+0131, utf8 c4b1 is the lower-case i without a dot QString sup = QString::fromUtf8("\xc4\xb1"); - QCOMPARE(sup.toUpper(), QString::fromLatin1("I")); - QCOMPARE(QString::fromLatin1("I").toLower(), sup); + QCOMPARE(l.toUpper(sup), QString::fromLatin1("I")); + QCOMPARE(l.toLower(QString::fromLatin1("I")), sup); // nothing should happen here - QCOMPARE(sup.toLower(), sup); - QCOMPARE(QString::fromLatin1("i").toLower(), QString::fromLatin1("i")); + QCOMPARE(l.toLower(sup), sup); + QCOMPARE(l.toLower(QString::fromLatin1("i")), QString::fromLatin1("i")); // the cleanup function will restore the default locale } -- cgit v0.12 From 5ee3e4964d60f4d9cd7026c6f8b6fb93ddd39588 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Samuel=20R=C3=B8dal?= Date: Tue, 12 Jul 2011 13:16:45 +0200 Subject: Deprecate some functions in QImage (that have been obsolete since 4.1). Reviewed-by: Olivier Goffart --- src/gui/image/qimage.h | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/src/gui/image/qimage.h b/src/gui/image/qimage.h index c783b76..57d7169 100644 --- a/src/gui/image/qimage.h +++ b/src/gui/image/qimage.h @@ -66,7 +66,8 @@ template class QVector; struct QImageData; class QImageDataMisc; // internal #ifndef QT_NO_IMAGE_TEXT -class Q_GUI_EXPORT QImageTextKeyLang { +#ifdef QT_DEPRECATED +class Q_GUI_EXPORT QT_DEPRECATED QImageTextKeyLang { public: QImageTextKeyLang(const char* k, const char* l) : key(k), lang(l) { } QImageTextKeyLang() { } @@ -81,6 +82,7 @@ public: inline bool operator!= (const QImageTextKeyLang &other) const { return !operator==(other); } }; +#endif #endif //QT_NO_IMAGE_TEXT @@ -275,12 +277,13 @@ public: QString text(const QString &key = QString()) const; void setText(const QString &key, const QString &value); - // The following functions are obsolete as of 4.1 - QString text(const char* key, const char* lang=0) const; - QList textList() const; - QStringList textLanguages() const; - QString text(const QImageTextKeyLang&) const; - void setText(const char* key, const char* lang, const QString&); +#ifdef QT_DEPRECATED + QT_DEPRECATED QString text(const char* key, const char* lang=0) const; + QT_DEPRECATED QList textList() const; + QT_DEPRECATED QStringList textLanguages() const; + QT_DEPRECATED QString text(const QImageTextKeyLang&) const; + QT_DEPRECATED void setText(const char* key, const char* lang, const QString&); +#endif #endif #ifdef QT3_SUPPORT -- cgit v0.12 From fb4903c4eca6a085c4c39078c11de03f5791f08e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Samuel=20R=C3=B8dal?= Date: Tue, 12 Jul 2011 14:33:53 +0200 Subject: Deprecate some QPixmap functions (marked as obsolete already). Reviewed-by: Olivier Goffart --- src/gui/image/qpixmap.h | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/src/gui/image/qpixmap.h b/src/gui/image/qpixmap.h index 4668913..f5479e7 100644 --- a/src/gui/image/qpixmap.h +++ b/src/gui/image/qpixmap.h @@ -109,8 +109,10 @@ public: QBitmap mask() const; void setMask(const QBitmap &); - QPixmap alphaChannel() const; - void setAlphaChannel(const QPixmap &); +#ifdef QT_DEPRECATED + QT_DEPRECATED QPixmap alphaChannel() const; + QT_DEPRECATED void setAlphaChannel(const QPixmap &); +#endif bool hasAlpha() const; bool hasAlphaChannel() const; @@ -183,7 +185,9 @@ public: inline void scroll(int dx, int dy, int x, int y, int width, int height, QRegion *exposed = 0); void scroll(int dx, int dy, const QRect &rect, QRegion *exposed = 0); - int serialNumber() const; +#ifdef QT_DEPRECATED + QT_DEPRECATED int serialNumber() const; +#endif qint64 cacheKey() const; bool isDetached() const; -- cgit v0.12 From 705416cdc8ee91ac88d80298dbe2971a9384c196 Mon Sep 17 00:00:00 2001 From: Jiang Jiang Date: Thu, 14 Jul 2011 09:40:12 +0200 Subject: Apply 57993ba7 properly to 4.8 Because we have moved alignLine from qtextlayout.cpp to QTextEngine, this patch has to be applied manually. Reviewed-by: TrustMe --- src/gui/text/qtextengine.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/gui/text/qtextengine.cpp b/src/gui/text/qtextengine.cpp index db50bdf..d92c418 100644 --- a/src/gui/text/qtextengine.cpp +++ b/src/gui/text/qtextengine.cpp @@ -2808,7 +2808,7 @@ QFixed QTextEngine::alignLine(const QScriptLine &line) if (align & Qt::AlignRight) x = line.width - (line.textAdvance + leadingSpaceWidth(line)); else if (align & Qt::AlignHCenter) - x = (line.width - (line.textAdvance + leadingSpaceWidth(line)))/2; + x = (line.width - line.textAdvance)/2 - leadingSpaceWidth(line); } return x; } -- cgit v0.12 From 13d58a14da191cf7a5cdccc7a3d27dcf2309a928 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Samuel=20R=C3=B8dal?= Date: Thu, 14 Jul 2011 10:27:56 +0200 Subject: Properly quit the input event thread in the directfb platform plugin. Reviewed-by: Girish Ramakrishnan --- src/plugins/platforms/directfb/qdirectfbintegration.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/plugins/platforms/directfb/qdirectfbintegration.cpp b/src/plugins/platforms/directfb/qdirectfbintegration.cpp index 61f1d25..06b0b51 100644 --- a/src/plugins/platforms/directfb/qdirectfbintegration.cpp +++ b/src/plugins/platforms/directfb/qdirectfbintegration.cpp @@ -112,6 +112,8 @@ QDirectFbIntegration::QDirectFbIntegration() QDirectFbIntegration::~QDirectFbIntegration() { mInput->stopInputEventLoop(); + mInputRunner->quit(); + mInputRunner->wait(); delete mInputRunner; delete mInput; } -- cgit v0.12 From 80bc39a4560577f1c9d5e6dc0068a7d241c29aec Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Samuel=20R=C3=B8dal?= Date: Fri, 15 Jul 2011 12:45:35 +0200 Subject: Fixed regression in compilerwarnings. We can't mark QImageTextKeyLang as deprecated. --- src/gui/image/qimage.h | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/src/gui/image/qimage.h b/src/gui/image/qimage.h index 57d7169..2aeb3de 100644 --- a/src/gui/image/qimage.h +++ b/src/gui/image/qimage.h @@ -66,8 +66,7 @@ template class QVector; struct QImageData; class QImageDataMisc; // internal #ifndef QT_NO_IMAGE_TEXT -#ifdef QT_DEPRECATED -class Q_GUI_EXPORT QT_DEPRECATED QImageTextKeyLang { +class Q_GUI_EXPORT QImageTextKeyLang { public: QImageTextKeyLang(const char* k, const char* l) : key(k), lang(l) { } QImageTextKeyLang() { } @@ -82,7 +81,6 @@ public: inline bool operator!= (const QImageTextKeyLang &other) const { return !operator==(other); } }; -#endif #endif //QT_NO_IMAGE_TEXT -- cgit v0.12 From 947aaa79b05adec527c7500e36766c7ff19f118d Mon Sep 17 00:00:00 2001 From: Mirko Vogt Date: Mon, 18 Jul 2011 12:42:32 +0200 Subject: Add support for opening LinuxInput devices exclusively ('grabbing'). MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The LinuxInput stack exposes the ioctl EVIOCGRAB which allows LinuxInput devices being opened exclusively ('grabbed'). This patch adds support for configuring how Qt should treat LinuxInput devices (via the 'grab'-argument). By default devices are not grabbed, so not opened exclusively (matches prior behaviour). This however means all input (keystrokes, etc.) is passed to other applications (shells/ttys included) accessing respective device(s) as well. Merge-request: 2637 Reviewed-by: Jørgen Lind --- src/gui/embedded/qkbdlinuxinput_qws.cpp | 4 ++++ src/gui/embedded/qmouselinuxinput_qws.cpp | 13 +++++++++++-- 2 files changed, 15 insertions(+), 2 deletions(-) diff --git a/src/gui/embedded/qkbdlinuxinput_qws.cpp b/src/gui/embedded/qkbdlinuxinput_qws.cpp index 376b0d0..b2e7cb3 100644 --- a/src/gui/embedded/qkbdlinuxinput_qws.cpp +++ b/src/gui/embedded/qkbdlinuxinput_qws.cpp @@ -103,6 +103,7 @@ QWSLinuxInputKbPrivate::QWSLinuxInputKbPrivate(QWSLinuxInputKeyboardHandler *h, QString dev = QLatin1String("/dev/input/event1"); int repeat_delay = -1; int repeat_rate = -1; + int grab = 0; QStringList args = device.split(QLatin1Char(':')); foreach (const QString &arg, args) { @@ -110,12 +111,15 @@ QWSLinuxInputKbPrivate::QWSLinuxInputKbPrivate(QWSLinuxInputKeyboardHandler *h, repeat_delay = arg.mid(13).toInt(); else if (arg.startsWith(QLatin1String("repeat-rate="))) repeat_rate = arg.mid(12).toInt(); + else if (arg.startsWith(QLatin1String("grab="))) + grab = arg.mid(5).toInt(); else if (arg.startsWith(QLatin1String("/dev/"))) dev = arg; } m_fd = QT_OPEN(dev.toLocal8Bit().constData(), O_RDWR, 0); if (m_fd >= 0) { + ::ioctl(m_fd, EVIOCGRAB, grab); if (repeat_delay > 0 && repeat_rate > 0) { int kbdrep[2] = { repeat_delay, repeat_rate }; ::ioctl(m_fd, EVIOCSREP, kbdrep); diff --git a/src/gui/embedded/qmouselinuxinput_qws.cpp b/src/gui/embedded/qmouselinuxinput_qws.cpp index 19a9a99..5b4f664 100644 --- a/src/gui/embedded/qmouselinuxinput_qws.cpp +++ b/src/gui/embedded/qmouselinuxinput_qws.cpp @@ -43,6 +43,7 @@ #include #include +#include #include #include // overrides QT_OPEN @@ -101,11 +102,19 @@ QWSLinuxInputMousePrivate::QWSLinuxInputMousePrivate(QWSLinuxInputMouseHandler * setObjectName(QLatin1String("LinuxInputSubsystem Mouse Handler")); QString dev = QLatin1String("/dev/input/event0"); - if (device.startsWith(QLatin1String("/dev/"))) - dev = device; + int grab = 0; + + QStringList args = device.split(QLatin1Char(':')); + foreach (const QString &arg, args) { + if (arg.startsWith(QLatin1String("grab="))) + grab = arg.mid(5).toInt(); + else if (arg.startsWith(QLatin1String("/dev/"))) + dev = arg; + } m_fd = QT_OPEN(dev.toLocal8Bit().constData(), O_RDONLY | O_NDELAY, 0); if (m_fd >= 0) { + ::ioctl(m_fd, EVIOCGRAB, grab); m_notify = new QSocketNotifier(m_fd, QSocketNotifier::Read, this); connect(m_notify, SIGNAL(activated(int)), this, SLOT(readMouseData())); } else { -- cgit v0.12 From e074334240d3901e28d4e8a6f28aa7da9481a72b Mon Sep 17 00:00:00 2001 From: Eike Ziller Date: Mon, 18 Jul 2011 16:58:45 +0200 Subject: Support interface orientation for uikit. Rotates app status bar. Adheres to UISupportedInterfaceOrientations and UIInterfaceOrientation. --- src/plugins/platforms/uikit/quikiteventloop.mm | 65 ++++++++++++++++++++++- src/plugins/platforms/uikit/quikitintegration.h | 2 + src/plugins/platforms/uikit/quikitintegration.mm | 9 ++++ src/plugins/platforms/uikit/quikitscreen.h | 1 + src/plugins/platforms/uikit/quikitscreen.mm | 26 ++++++++- src/plugins/platforms/uikit/quikitwindow.h | 4 ++ src/plugins/platforms/uikit/quikitwindow.mm | 67 ++++++++++++++++++------ 7 files changed, 155 insertions(+), 19 deletions(-) diff --git a/src/plugins/platforms/uikit/quikiteventloop.mm b/src/plugins/platforms/uikit/quikiteventloop.mm index 7c3e929..01ecf3f 100644 --- a/src/plugins/platforms/uikit/quikiteventloop.mm +++ b/src/plugins/platforms/uikit/quikiteventloop.mm @@ -40,6 +40,8 @@ ****************************************************************************/ #include "quikiteventloop.h" +#include "quikitintegration.h" +#include "quikitscreen.h" #include "quikitwindow.h" #include "quikitwindowsurface.h" @@ -50,7 +52,11 @@ #include @interface QUIKitAppDelegate : NSObject { + UIInterfaceOrientation mOrientation; } + +- (void)updateOrientation:(NSNotification *)notification; + @end @interface EventLoopHelper : NSObject { @@ -69,14 +75,71 @@ - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions { Q_UNUSED(launchOptions) - Q_UNUSED(application) + mOrientation = application.statusBarOrientation; + [self updateOrientation:nil]; + if (QUIKitIntegration::instance()->screens().size() > 0) { + QUIKitScreen *screen = static_cast(QUIKitIntegration::instance()->screens().at(0)); + screen->updateInterfaceOrientation(); + } foreach (QWidget *widget, qApp->topLevelWidgets()) { QUIKitWindow *platformWindow = static_cast(widget->platformWindow()); if (platformWindow) platformWindow->ensureNativeWindow(); } + // orientation support + [[UIDevice currentDevice] beginGeneratingDeviceOrientationNotifications]; + [[NSNotificationCenter defaultCenter] addObserver:self + selector:@selector(updateOrientation:) + name:UIDeviceOrientationDidChangeNotification + object:nil]; return YES; } +- (void)updateOrientation:(NSNotification *)notification +{ + Q_UNUSED(notification) + UIInterfaceOrientation newOrientation = mOrientation; + NSString *infoValue = @""; + switch ([UIDevice currentDevice].orientation) { + case UIDeviceOrientationUnknown: + break; + case UIDeviceOrientationPortrait: + newOrientation = UIInterfaceOrientationPortrait; + infoValue = @"UIInterfaceOrientationPortrait"; + break; + case UIDeviceOrientationPortraitUpsideDown: + newOrientation = UIInterfaceOrientationPortraitUpsideDown; + infoValue = @"UIInterfaceOrientationPortraitUpsideDown"; + break; + case UIDeviceOrientationLandscapeLeft: + newOrientation = UIInterfaceOrientationLandscapeRight; // as documentated + infoValue = @"UIInterfaceOrientationLandscapeRight"; + break; + case UIDeviceOrientationLandscapeRight: + newOrientation = UIInterfaceOrientationLandscapeLeft; // as documentated + infoValue = @"UIInterfaceOrientationLandscapeLeft"; + break; + case UIDeviceOrientationFaceUp: + case UIDeviceOrientationFaceDown: + break; + } + + if (newOrientation == mOrientation) + return; + + // check against supported orientations + NSBundle *bundle = [NSBundle mainBundle]; + NSArray *orientations = [bundle objectForInfoDictionaryKey:@"UISupportedInterfaceOrientations"]; + if (![orientations containsObject:infoValue]) + return; + + mOrientation = newOrientation; + [UIApplication sharedApplication].statusBarOrientation = mOrientation; + if (QUIKitIntegration::instance()->screens().size() > 0) { + QUIKitScreen *screen = static_cast(QUIKitIntegration::instance()->screens().at(0)); + screen->updateInterfaceOrientation(); + } +} + - (void)applicationWillTerminate:(UIApplication *)application { Q_UNUSED(application) diff --git a/src/plugins/platforms/uikit/quikitintegration.h b/src/plugins/platforms/uikit/quikitintegration.h index d9844b2..a392f1d 100644 --- a/src/plugins/platforms/uikit/quikitintegration.h +++ b/src/plugins/platforms/uikit/quikitintegration.h @@ -52,6 +52,8 @@ public: QUIKitIntegration(); ~QUIKitIntegration(); + static QUIKitIntegration *instance(); + QPixmapData *createPixmapData(QPixmapData::PixelType type) const; QPlatformWindow *createPlatformWindow(QWidget *widget, WId winId = 0) const; QWindowSurface *createWindowSurface(QWidget *widget, WId winId) const; diff --git a/src/plugins/platforms/uikit/quikitintegration.mm b/src/plugins/platforms/uikit/quikitintegration.mm index 21ab38f..ca020c9 100644 --- a/src/plugins/platforms/uikit/quikitintegration.mm +++ b/src/plugins/platforms/uikit/quikitintegration.mm @@ -66,9 +66,18 @@ public: } }; +static QUIKitIntegration *m_instance = 0; + +QUIKitIntegration * QUIKitIntegration::instance() +{ + return m_instance; +} + QUIKitIntegration::QUIKitIntegration() :mFontDb(new QUIKitFontDatabase() ) { + if (!m_instance) + m_instance = this; mScreens << new QUIKitScreen(0); } diff --git a/src/plugins/platforms/uikit/quikitscreen.h b/src/plugins/platforms/uikit/quikitscreen.h index 23e95f6..1b17d60 100644 --- a/src/plugins/platforms/uikit/quikitscreen.h +++ b/src/plugins/platforms/uikit/quikitscreen.h @@ -61,6 +61,7 @@ public: UIScreen *uiScreen() const; + void updateInterfaceOrientation(); private: QRect m_geometry; int m_depth; diff --git a/src/plugins/platforms/uikit/quikitscreen.mm b/src/plugins/platforms/uikit/quikitscreen.mm index ae1c7cf..d7d8207 100644 --- a/src/plugins/platforms/uikit/quikitscreen.mm +++ b/src/plugins/platforms/uikit/quikitscreen.mm @@ -40,6 +40,7 @@ ****************************************************************************/ #include "quikitscreen.h" +#include "quikitwindow.h" #include @@ -52,8 +53,7 @@ QUIKitScreen::QUIKitScreen(int screenIndex) m_index(screenIndex) { NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init]; - UIScreen *screen = [[UIScreen screens] objectAtIndex:screenIndex]; - CGRect bounds = [screen bounds]; + CGRect bounds = [uiScreen() bounds]; m_geometry = QRect(bounds.origin.x, bounds.origin.y, bounds.size.width, bounds.size.height); m_format = QImage::Format_ARGB32; @@ -87,4 +87,26 @@ UIScreen *QUIKitScreen::uiScreen() const return [[UIScreen screens] objectAtIndex:m_index]; } +void QUIKitScreen::updateInterfaceOrientation() +{ + CGRect bounds = [uiScreen() bounds]; + switch ([[UIApplication sharedApplication] statusBarOrientation]) { + case UIInterfaceOrientationPortrait: + case UIInterfaceOrientationPortraitUpsideDown: + m_geometry = QRect(bounds.origin.x, bounds.origin.y, bounds.size.width, bounds.size.height);; + break; + case UIInterfaceOrientationLandscapeLeft: + case UIInterfaceOrientationLandscapeRight: + m_geometry = QRect(bounds.origin.x, bounds.origin.y, + bounds.size.height, bounds.size.width); + break; + } + foreach (QWidget *widget, qApp->topLevelWidgets()) { + QUIKitWindow *platformWindow = static_cast(widget->platformWindow()); + if (platformWindow && platformWindow->platformScreen() == this) { + platformWindow->updateGeometryAndOrientation(); + } + } +} + QT_END_NAMESPACE diff --git a/src/plugins/platforms/uikit/quikitwindow.h b/src/plugins/platforms/uikit/quikitwindow.h index c482dae..c91b751 100644 --- a/src/plugins/platforms/uikit/quikitwindow.h +++ b/src/plugins/platforms/uikit/quikitwindow.h @@ -119,9 +119,13 @@ public: QPlatformGLContext *glContext() const; + QUIKitScreen *platformScreen() const { return mScreen; } + + void updateGeometryAndOrientation(); private: QUIKitScreen *mScreen; UIWindow *mWindow; + CGRect mFrame; EAGLView *mView; mutable EAGLPlatformContext *mContext; }; diff --git a/src/plugins/platforms/uikit/quikitwindow.mm b/src/plugins/platforms/uikit/quikitwindow.mm index ec33cd0..6e018fe 100644 --- a/src/plugins/platforms/uikit/quikitwindow.mm +++ b/src/plugins/platforms/uikit/quikitwindow.mm @@ -320,10 +320,7 @@ QUIKitWindow::QUIKitWindow(QWidget *tlw) : mContext(0) { mScreen = static_cast(QPlatformScreen::platformScreenForWidget(tlw)); - CGRect screenBounds = [mScreen->uiScreen() bounds]; - QRect geom(screenBounds.origin.x, screenBounds.origin.y, screenBounds.size.width, screenBounds.size.height); - QPlatformWindow::setGeometry(geom); - mView = [[EAGLView alloc] initWithFrame:CGRectMake(geom.x(), geom.y(), geom.width(), geom.height())]; + mView = [[EAGLView alloc] init]; } QUIKitWindow::~QUIKitWindow() @@ -335,29 +332,23 @@ QUIKitWindow::~QUIKitWindow() void QUIKitWindow::setGeometry(const QRect &rect) { - if (mWindow && rect != geometry()) { - mWindow.frame = CGRectMake(rect.x(), rect.y(), rect.width(), rect.height()); - mView.frame = CGRectMake(0, 0, rect.width(), rect.height()); - [mView deleteFramebuffer]; - [mWindow setNeedsDisplay]; - } + // Not supported. Only a single "full screen" window is supported QPlatformWindow::setGeometry(rect); } UIWindow *QUIKitWindow::ensureNativeWindow() { if (!mWindow) { - // window - CGRect frame = [mScreen->uiScreen() applicationFrame]; - QRect geom = QRect(frame.origin.x, frame.origin.y, frame.size.width, frame.size.height); - widget()->setGeometry(geom); mWindow = [[UIWindow alloc] init]; + updateGeometryAndOrientation(); + // window mWindow.screen = mScreen->uiScreen(); - mWindow.frame = frame; // for some reason setting the screen resets frame.origin, so we need to set the frame afterwards + // for some reason setting the screen resets frame.origin, so we need to set the frame afterwards + mWindow.frame = mFrame; // view [mView deleteFramebuffer]; - mView.frame = CGRectMake(0, 0, frame.size.width, frame.size.height); // fill + mView.frame = CGRectMake(0, 0, mWindow.bounds.size.width, mWindow.bounds.size.height); // fill [mView setMultipleTouchEnabled:YES]; [mView setWindow:this]; [mWindow addSubview:mView]; @@ -367,6 +358,50 @@ UIWindow *QUIKitWindow::ensureNativeWindow() return mWindow; } +void QUIKitWindow::updateGeometryAndOrientation() +{ + if (!mWindow) + return; + mFrame = [mScreen->uiScreen() applicationFrame]; + CGRect screen = [mScreen->uiScreen() bounds]; + QRect geom; + CGFloat angle = 0; + switch ([[UIApplication sharedApplication] statusBarOrientation]) { + case UIInterfaceOrientationPortrait: + geom = QRect(mFrame.origin.x, mFrame.origin.y, mFrame.size.width, mFrame.size.height); + break; + case UIInterfaceOrientationPortraitUpsideDown: + geom = QRect(screen.size.width - mFrame.origin.x - mFrame.size.width, + screen.size.height - mFrame.origin.y - mFrame.size.height, + mFrame.size.width, + mFrame.size.height); + angle = M_PI; + break; + case UIInterfaceOrientationLandscapeLeft: + geom = QRect(screen.size.height - mFrame.origin.y - mFrame.size.height, + mFrame.origin.x, + mFrame.size.height, + mFrame.size.width); + angle = -M_PI/2.; + break; + case UIInterfaceOrientationLandscapeRight: + geom = QRect(mFrame.origin.y, + screen.size.width - mFrame.origin.x - mFrame.size.width, + mFrame.size.height, + mFrame.size.width); + angle = +M_PI/2.; + break; + } + if (angle != 0) { + [mView layer].transform = CATransform3DMakeRotation(angle, 0, 0, 1.); + } else { + [mView layer].transform = CATransform3DIdentity; + } + [mView setNeedsDisplay]; + widget()->setGeometry(geom); + widget()->update(); +} + QPlatformGLContext *QUIKitWindow::glContext() const { if (!mContext) { -- cgit v0.12 From db17ebe4510371b3b007c3852f2d1110abefbdda Mon Sep 17 00:00:00 2001 From: Jiang Jiang Date: Mon, 18 Jul 2011 11:07:33 +0200 Subject: Skip shaping for hidden line/paragraph separators Since we are not going to draw them in QTextLine::draw either, and shaping them here will cause performance issue on certain systems like Mac OS X 10.7 (most fonts don't have glyph for U+2028, while font fallback handling in Core Text slowed down a bit). Task-number: QTBUG-20252 Reviewed-by: Eskil --- src/gui/text/qtextengine.cpp | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/gui/text/qtextengine.cpp b/src/gui/text/qtextengine.cpp index d92c418..dd93cae 100644 --- a/src/gui/text/qtextengine.cpp +++ b/src/gui/text/qtextengine.cpp @@ -897,6 +897,12 @@ void QTextEngine::shapeText(int item) const if (si.num_glyphs) return; + // Skip shaping of line or paragraph separators since we are not + // going to draw them anyway + if (si.analysis.flags == QScriptAnalysis::LineOrParagraphSeparator + && !(option.flags() & QTextOption::ShowLineAndParagraphSeparators)) + return; + #if defined(Q_WS_MAC) #if !defined(QT_ENABLE_HARFBUZZ_FOR_MAC) if (enableHarfBuzz()) { -- cgit v0.12 From b683aaa27430ced087b4230e031f56c3100f8068 Mon Sep 17 00:00:00 2001 From: Jiang Jiang Date: Tue, 19 Jul 2011 14:55:30 +0200 Subject: Move separator skipping to proper place So that it won't crash some places that requires shaping results. Reviewed-by: TrustMe --- src/gui/text/qtextengine.cpp | 6 ------ src/gui/text/qtextengine_mac.cpp | 7 +++++++ 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/src/gui/text/qtextengine.cpp b/src/gui/text/qtextengine.cpp index dd93cae..d92c418 100644 --- a/src/gui/text/qtextengine.cpp +++ b/src/gui/text/qtextengine.cpp @@ -897,12 +897,6 @@ void QTextEngine::shapeText(int item) const if (si.num_glyphs) return; - // Skip shaping of line or paragraph separators since we are not - // going to draw them anyway - if (si.analysis.flags == QScriptAnalysis::LineOrParagraphSeparator - && !(option.flags() & QTextOption::ShowLineAndParagraphSeparators)) - return; - #if defined(Q_WS_MAC) #if !defined(QT_ENABLE_HARFBUZZ_FOR_MAC) if (enableHarfBuzz()) { diff --git a/src/gui/text/qtextengine_mac.cpp b/src/gui/text/qtextengine_mac.cpp index 251d9b5..9da8f03 100644 --- a/src/gui/text/qtextengine_mac.cpp +++ b/src/gui/text/qtextengine_mac.cpp @@ -605,6 +605,12 @@ void QTextEngine::shapeTextMac(int item) const unsigned short *log_clusters = logClusters(&si); bool stringToCMapFailed = false; + // Skip shaping of line or paragraph separators since we are not + // going to draw them anyway + if (si.analysis.flags == QScriptAnalysis::LineOrParagraphSeparator + && !(option.flags() & QTextOption::ShowLineAndParagraphSeparators)) + goto cleanUp; + if (!fe->stringToCMap(str, len, &g, &num_glyphs, flags, log_clusters, attributes(), &si)) { ensureSpace(num_glyphs); g = availableGlyphs(&si); @@ -645,6 +651,7 @@ void QTextEngine::shapeTextMac(int item) const } } +cleanUp: const ushort *uc = reinterpret_cast(str); if ((si.analysis.flags == QScriptAnalysis::SmallCaps || si.analysis.flags == QScriptAnalysis::Uppercase -- cgit v0.12