Bug 842805 - Use of API deprecated in Qt5. r=romaxa, r=glandium
authorTatiana Meshkova <tanya.meshkova@gmail.com>
Mon, 25 Feb 2013 12:25:16 -0800
changeset 133356 f826daae4e6534a2d84e47e746ee018130e33f6b
parent 133355 1eadb5490d75c0f10816290989cd63cde907e480
child 133357 d61843b7a08141d7ed26f2cd9b0b633f13f18baa
push idunknown
push userunknown
push dateunknown
reviewersromaxa, glandium
bugs842805
milestone22.0a1
Bug 842805 - Use of API deprecated in Qt5. r=romaxa, r=glandium
configure.in
gfx/cairo/cairo/src/cairo-qt-surface.cpp
gfx/thebes/gfxQtPlatform.cpp
intl/locale/src/nsLocaleService.cpp
toolkit/xre/nsQAppInstance.cpp
widget/qt/nsBidiKeyboard.cpp
widget/qt/nsDeviceContextSpecQt.cpp
widget/qt/nsNativeThemeQt.cpp
widget/qt/nsWindow.cpp
--- a/configure.in
+++ b/configure.in
@@ -4668,47 +4668,50 @@ dnl ====================================
 if test "$MOZ_ENABLE_QT"
 then
     MOZ_ARG_WITH_STRING(qtdir,
     [  --with-qtdir=\$dir       Specify Qt directory ],
     [ QTDIR=$withval])
 
     if test -z "$QTDIR"; then
         PKG_CHECK_MODULES(MOZ_QT, QtGui QtNetwork QtCore QtOpenGL)
-        PKG_CHECK_MODULES(MOZ_QT5, QtWidgets QtMultimedia QtPrintSupport,
+        PKG_CHECK_MODULES(MOZ_QT5, Qt5Widgets Qt5Multimedia Qt5PrintSupport,
                       MOZ_ENABLE_QT5=1,
                       MOZ_ENABLE_QT5=)
         if test "$MOZ_ENABLE_QT5"; then
             echo "Using qt5"
             MOZ_QT_CFLAGS="$MOZ_QT_CFLAGS $MOZ_QT5_CFLAGS"
             MOZ_QT_LIBS="$MOZ_QT_LIBS $MOZ_QT5_LIBS"
         fi
 
         AC_CHECK_PROGS(HOST_MOC, $MOC moc, "")
         AC_CHECK_PROGS(HOST_RCC, $RCC rcc, "")
     else
-        MOZ_QT_LIBS="-L$QTDIR/lib/ -lQtGui -lQtNetwork -lQtCore -lQtXml -lQtOpenGL"
-
         MOZ_QT_CFLAGS="-DQT_SHARED"
         MOZ_QT_CFLAGS="$MOZ_QT_CFLAGS -I$QTDIR/include"
-        MOZ_QT_CFLAGS="$MOZ_QT_CFLAGS -I$QTDIR/include/Qt"
         MOZ_QT_CFLAGS="$MOZ_QT_CFLAGS -I$QTDIR/include/QtGui"
         MOZ_QT_CFLAGS="$MOZ_QT_CFLAGS -I$QTDIR/include/QtCore"
         MOZ_QT_CFLAGS="$MOZ_QT_CFLAGS -I$QTDIR/include/QtNetwork"
         MOZ_QT_CFLAGS="$MOZ_QT_CFLAGS -I$QTDIR/include/QtXml"
         MOZ_QT_CFLAGS="$MOZ_QT_CFLAGS -I$QTDIR/include/QtDeclarative"
-        HOST_MOC="$QTDIR/bin/moc"
-        HOST_RCC="$QTDIR/bin/rcc"
 
         # QtWidgets was introduced only in Qt5
         if test -d $QTDIR/include/QtWidgets; then
+            echo "Using qt5"
+            MOZ_QT_LIBS="-L$QTDIR/lib/ -lQt5Gui -lQt5Network -lQt5Core -lQt5Xml -lQt5OpenGL"
+            MOZ_QT_CFLAGS="$MOZ_QT_CFLAGS -I$QTDIR/include/QtGui/5.0.1/QtGui"
             MOZ_QT_CFLAGS="$MOZ_QT_CFLAGS -I$QTDIR/include/QtWidgets"
             MOZ_QT_CFLAGS="$MOZ_QT_CFLAGS -I$QTDIR/include/QtPrintSupport"
-            MOZ_QT_LIBS="$MOZ_QT_LIBS -lQtWidgets -lQtPrintSupport"
+            MOZ_QT_LIBS="$MOZ_QT_LIBS -lQt5Widgets -lQt5PrintSupport"
+        else
+            MOZ_QT_LIBS="-L$QTDIR/lib/ -lQtGui -lQtNetwork -lQtCore -lQtXml -lQtOpenGL"
+            MOZ_QT_CFLAGS="$MOZ_QT_CFLAGS -I$QTDIR/include/Qt"
         fi
+        HOST_MOC="$QTDIR/bin/moc"
+        HOST_RCC="$QTDIR/bin/rcc"
     fi
     if test -z "$HOST_MOC"; then
         AC_MSG_ERROR([No acceptable moc preprocessor found. Qt SDK is not installed or --with-qt is
 incorrect])
     fi
     if test -z "$HOST_RCC"; then
         AC_MSG_ERROR([No acceptable rcc preprocessor found. Qt SDK is not installed or --with-qt is
 incorrect])
--- a/gfx/cairo/cairo/src/cairo-qt-surface.cpp
+++ b/gfx/cairo/cairo/src/cairo-qt-surface.cpp
@@ -723,17 +723,17 @@ static void
 	QRegion qr;
 	int num_rects = cairo_region_num_rectangles (clip_region);
 	for (int i = 0; i < num_rects; ++i) {
 	    cairo_rectangle_int_t rect;
 
 	    cairo_region_get_rectangle (clip_region, i, &rect);
 
 	    QRect r(rect.x, rect.y, rect.width, rect.height);
-	    qr = qr.unite(r);
+	    qr = qr.united(r);
 	}
 
 	qs->p->setClipRegion (qr, Qt::IntersectClip);
     }
 }
 
 static cairo_int_status_t
 _cairo_qt_surface_set_clip (cairo_qt_surface_t *qs,
--- a/gfx/thebes/gfxQtPlatform.cpp
+++ b/gfx/thebes/gfxQtPlatform.cpp
@@ -3,17 +3,18 @@
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 #include <QPixmap>
 #include <qglobal.h>
 #if (QT_VERSION < QT_VERSION_CHECK(5,0,0))
 #  include <QX11Info>
 #else
-#  include <QPlatformNativeInterface>
+#  include <qpa/qplatformnativeinterface.h>
+#  include <qpa/qplatformintegration.h>
 #endif
 #include <QApplication>
 #include <QDesktopWidget>
 #include <QPaintEngine>
 
 #include "gfxQtPlatform.h"
 
 #include "gfxFontconfigUtils.h"
--- a/intl/locale/src/nsLocaleService.cpp
+++ b/intl/locale/src/nsLocaleService.cpp
@@ -123,17 +123,17 @@ nsLocaleService::nsLocaleService(void)
     rv = NewLocale(xpLocale, getter_AddRefs(mApplicationLocale));
     NS_ENSURE_SUCCESS_VOID(rv);
 #endif
 #if defined(XP_UNIX) && !defined(XP_MACOSX)
     nsRefPtr<nsLocale> resultLocale(new nsLocale());
     NS_ENSURE_TRUE_VOID(resultLocale);
 
 #ifdef MOZ_WIDGET_QT
-    const char* lang = QLocale::system().name().toAscii();
+    const char* lang = QLocale::system().name().toUtf8();
 #else
     // Get system configuration
     const char* lang = getenv("LANG");
 #endif
 
     nsAutoString xpLocale, platformLocale;
     nsAutoString category, category_platform;
     int i;
--- a/toolkit/xre/nsQAppInstance.cpp
+++ b/toolkit/xre/nsQAppInstance.cpp
@@ -18,20 +18,22 @@ QApplication *nsQAppInstance::sQAppInsta
 MComponentData* nsQAppInstance::sMComponentData = NULL;
 #endif
 int nsQAppInstance::sQAppRefCount = 0;
 
 void nsQAppInstance::AddRef(int& aArgc, char** aArgv, bool aDefaultProcess) {
   if (qApp)
     return;
   if (!sQAppInstance) {
+#if (QT_VERSION < QT_VERSION_CHECK(5,0,0))
     const char *graphicsSystem = getenv("MOZ_QT_GRAPHICSSYSTEM");
     if (graphicsSystem) {
       QApplication::setGraphicsSystem(QString(graphicsSystem));
     }
+#endif
 #if (MOZ_PLATFORM_MAEMO == 6)
     // Should create simple windows style for non chrome process
     // otherwise meegotouch style initialize and crash happen
     // because we don't initialize MComponent for child process
     if (!aDefaultProcess) {
       QApplication::setStyle(QLatin1String("windows"));
     }
     if (!aArgc) {
--- a/widget/qt/nsBidiKeyboard.cpp
+++ b/widget/qt/nsBidiKeyboard.cpp
@@ -19,17 +19,22 @@ nsBidiKeyboard::nsBidiKeyboard() : nsIBi
 nsBidiKeyboard::~nsBidiKeyboard()
 {
 }
 
 NS_IMETHODIMP nsBidiKeyboard::IsLangRTL(bool *aIsRTL)
 {
     *aIsRTL = false;
 
+#if (QT_VERSION < QT_VERSION_CHECK(5,0,0))
     Qt::LayoutDirection layoutDir = QApplication::keyboardInputDirection();
+#else
+    QInputMethod* input = qApp->inputMethod();
+    Qt::LayoutDirection layoutDir = input ? input->inputDirection() : Qt::LeftToRight;
+#endif
 
     if (layoutDir == Qt::RightToLeft) {
         *aIsRTL = true;
     }
     
     return NS_OK;
 }
 
--- a/widget/qt/nsDeviceContextSpecQt.cpp
+++ b/widget/qt/nsDeviceContextSpecQt.cpp
@@ -82,17 +82,17 @@ NS_IMETHODIMP nsDeviceContextSpecQt::Get
 
     QTemporaryFile file;
     if(!file.open()) {
         return NS_ERROR_GFX_PRINTER_COULD_NOT_OPEN_FILE;
     }
     file.setAutoRemove(false);
 
     nsresult rv = NS_NewNativeLocalFile(
-            nsDependentCString(file.fileName().toAscii().constData()),
+            nsDependentCString(file.fileName().toUtf8().constData()),
             false,
             getter_AddRefs(mSpoolFile));
     if (NS_FAILED(rv)) {
         file.remove();
         return NS_ERROR_GFX_PRINTER_COULD_NOT_OPEN_FILE;
     }
 
     mSpoolName = file.fileName().toUtf8().constData();
--- a/widget/qt/nsNativeThemeQt.cpp
+++ b/widget/qt/nsNativeThemeQt.cpp
@@ -507,17 +507,17 @@ nsNativeThemeQt::GetMinimumWidgetSize(ns
     }
     return NS_OK;
 }
 
 NS_IMETHODIMP
 nsNativeThemeQt::WidgetStateChanged(nsIFrame* aFrame, uint8_t aWidgetType,
                                     nsIAtom* aAttribute, bool* aShouldRepaint)
 {
-    *aShouldRepaint = TRUE;
+    *aShouldRepaint = true;
     return NS_OK;
 }
 
 
 NS_IMETHODIMP
 nsNativeThemeQt::ThemeChanged()
 {
     QStyle *s = qApp->style();
--- a/widget/qt/nsWindow.cpp
+++ b/widget/qt/nsWindow.cpp
@@ -2165,17 +2165,17 @@ nsWindow::OnDragLeaveEvent(QGraphicsScen
     return DispatchEvent(&event);
 }
 
 nsEventStatus
 nsWindow::OnDragDropEvent(QGraphicsSceneDragDropEvent *aDropEvent)
 {
     if (aDropEvent->proposedAction() == Qt::CopyAction)
     {
-        printf("text version of the data: %s\n", aDropEvent->mimeData()->text().toAscii().data());
+        printf("text version of the data: %s\n", aDropEvent->mimeData()->text().toUtf8().data());
         aDropEvent->acceptProposedAction();
     }
 
     LOG(("nsWindow::OnDragDropSignal\n"));
     nsMouseEvent event(true, NS_DRAGDROP_OVER, 0,
                        nsMouseEvent::eReal);
     return nsEventStatus_eIgnore;
 }
@@ -3244,17 +3244,21 @@ nsWindow::SetInputContext(const InputCon
 }
 
 NS_IMETHODIMP_(InputContext)
 nsWindow::GetInputContext()
 {
     mInputContext.mIMEState.mOpen = IMEState::OPEN_STATE_NOT_SUPPORTED;
     // Our qt widget looks like using only one context per process.
     // However, it's better to set the context's pointer.
+#if (QT_VERSION <= QT_VERSION_CHECK(5, 0, 0))
     mInputContext.mNativeIMEContext = qApp->inputContext();
+#else
+    mInputContext.mNativeIMEContext = nullptr;
+#endif
     return mInputContext;
 }
 
 void
 nsWindow::SetSoftwareKeyboardState(bool aOpen,
                                    const InputContextAction& aAction)
 {
     if (aOpen) {