Bug 626632 - nsFilePicker is broken in qt desktop. r=romaxa a=npodb
authorTatiana Meshkova <tanya.meshkova@gmail.com>
Thu, 20 Jan 2011 08:27:47 +0200
changeset 60917 3a9a6b749df64db06ec671278c86af6cdb29c55f
parent 60916 8d45de3deeefb4b655c0e7ac133ed3294e0387fc
child 60918 a32b4edf277ae93b0c228f5ad81c87e15154fa82
push id18163
push userromaxa@gmail.com
push dateThu, 20 Jan 2011 06:28:04 +0000
treeherdermozilla-central@3b6ff0e5ecff [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersromaxa, npodb
bugs626632
milestone2.0b10pre
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 626632 - nsFilePicker is broken in qt desktop. r=romaxa a=npodb
widget/src/qt/nsFilePicker.cpp
widget/src/qt/nsWindow.h
--- a/widget/src/qt/nsFilePicker.cpp
+++ b/widget/src/qt/nsFilePicker.cpp
@@ -33,33 +33,28 @@
  * use your version of this file under the terms of the MPL, indicate your
  * decision by deleting the provisions above and replace them with the notice
  * and other provisions required by the GPL or the LGPL. If you do not delete
  * the provisions above, a recipient may use your version of this file under
  * the terms of any one of the MPL, the GPL or the LGPL.
  *
  * ***** END LICENSE BLOCK ***** */
 
-#include <qfile.h>
-#include <qstringlist.h>
-#include <qapplication.h>
-#include <qgraphicsproxywidget.h>
-#include <qgraphicswidget.h>
-#include <qgraphicsscene.h>
-
 #include "nsFilePicker.h"
 
 #include "nsILocalFile.h"
 #include "nsIURI.h"
 #include "nsISupportsArray.h"
 #include "nsMemory.h"
 #include "nsEnumeratorUtils.h"
 #include "nsNetUtil.h"
 #include "nsReadableUtils.h"
 #include "nsIWidget.h"
+#include "mozqwidget.h"
+#include "nsWindow.h"
 #include "prlog.h"
 
 #ifdef PR_LOGGING
 static PRLogModuleInfo* sFilePickerLog = nsnull;
 #endif
 
 /* Implementation file */
 NS_IMPL_ISUPPORTS1(nsFilePicker, nsIFilePicker)
@@ -281,18 +276,21 @@ nsFilePicker::Show(PRInt16 *aReturn)
 
     return NS_OK;
 }
 
 void nsFilePicker::InitNative(nsIWidget *parent, const nsAString &title, PRInt16 mode)
 {
     PR_LOG(sFilePickerLog, PR_LOG_DEBUG, ("nsFilePicker::InitNative"));
 
-    nsAutoString str(title);
-    mDialog = new QFileDialog(0, QString::fromUtf16(str.get()));
+    MozQWidget *parentMozWidget = (parent) ?
+        static_cast<MozQWidget*>(parent->GetNativeData(NS_NATIVE_WIDGET)) : nsnull;
+    QWidget *parentWidget = (parentMozWidget) ?
+        parentMozWidget->getReceiver()->GetViewWidget() : nsnull;
+    if (!parentWidget) {
+        NS_WARNING("Can't find parent for QFileDialog");
+    }
 
-    QGraphicsWidget *parentWidget = static_cast<QGraphicsWidget*>(parent->GetNativeData(NS_NATIVE_WIDGET));
-    if (parentWidget && parentWidget->scene()) {
-        parentWidget->scene()->addWidget(mDialog);
-    }
+    nsAutoString str(title);
+    mDialog = new QFileDialog(parentWidget, QString::fromUtf16(str.get()));
 
     mMode = mode;
 }
--- a/widget/src/qt/nsWindow.h
+++ b/widget/src/qt/nsWindow.h
@@ -228,16 +228,19 @@ public:
 
     // called when we are destroyed
     void OnDestroy(void);
 
     // called to check and see if a widget's dimensions are sane
     PRBool AreBoundsSane(void);
 
     NS_IMETHOD         ReparentNativeWidget(nsIWidget* aNewParent);
+
+    QWidget* GetViewWidget();
+
 protected:
     nsCOMPtr<nsIWidget> mParent;
     // Is this a toplevel window?
     PRPackedBool        mIsTopLevel;
     // Has this widget been destroyed yet?
     PRPackedBool        mIsDestroyed;
 
     // This flag tracks if we're hidden or shown.
@@ -340,17 +343,16 @@ private:
 
     void*              SetupPluginPort(void);
     nsresult           SetWindowIconList(const nsTArray<nsCString> &aIconList);
     void               SetDefaultIcon(void);
     void               InitButtonEvent(nsMouseEvent &event, QGraphicsSceneMouseEvent *aEvent, int aClickCount = 1);
     PRBool             DispatchCommandEvent(nsIAtom* aCommand);
     MozQWidget*        createQWidget(MozQWidget *parent, nsWidgetInitData *aInitData);
 
-    QWidget*           GetViewWidget();
     PRBool             IsAcceleratedQView(QGraphicsView* aView);
 
     MozQWidget*        mWidget;
 
     PRUint32           mIsVisible : 1,
                        mActivatePending : 1;
     PRInt32            mSizeState;
     PluginType         mPluginType;