changeset 831:831188672987

Make it possible to set the parent widget
author Chris Cannam
date Wed, 13 Aug 2014 16:42:25 +0100
parents 8bb9320f78a4
children 44acc0e5e004
files widgets/InteractiveFileFinder.cpp widgets/InteractiveFileFinder.h
diffstat 2 files changed, 14 insertions(+), 3 deletions(-) [+]
line wrap: on
line diff
--- a/widgets/InteractiveFileFinder.cpp	Fri Jul 25 17:02:29 2014 +0100
+++ b/widgets/InteractiveFileFinder.cpp	Wed Aug 13 16:42:25 2014 +0100
@@ -34,7 +34,8 @@
 
 InteractiveFileFinder::InteractiveFileFinder() :
     m_sessionExtension("sv"),
-    m_lastLocatedLocation("")
+    m_lastLocatedLocation(""),
+    m_parent(0)
 {
     SVDEBUG << "Registering interactive file finder" << endl;
     FileFinder::registerFileFinder(this);
@@ -45,6 +46,12 @@
 }
 
 void
+InteractiveFileFinder::setParentWidget(QWidget *parent)
+{
+    getInstance()->m_parent = parent;
+}
+
+void
 InteractiveFileFinder::setApplicationSessionExtension(QString extension)
 {
     m_sessionExtension = extension;
@@ -162,7 +169,7 @@
 
     // Use our own QFileDialog just for symmetry with getSaveFileName below
 
-    QFileDialog dialog;
+    QFileDialog dialog(m_parent);
     dialog.setNameFilters(filter.split('\n'));
     dialog.setWindowTitle(title);
     dialog.setDirectory(lastPath);
@@ -306,7 +313,7 @@
     // Use our own QFileDialog instead of static functions, as we may
     // need to adjust the file extension based on the selected filter
 
-    QFileDialog dialog;
+    QFileDialog dialog(m_parent);
 
     QStringList filters = filter.split('\n');
 
--- a/widgets/InteractiveFileFinder.h	Fri Jul 25 17:02:29 2014 +0100
+++ b/widgets/InteractiveFileFinder.h	Wed Aug 13 16:42:25 2014 +0100
@@ -44,6 +44,8 @@
 
     QString find(FileType type, QString location, QString lastKnownLocation = "");
 
+    static void setParentWidget(QWidget *);
+
     static InteractiveFileFinder *getInstance() { return &m_instance; }
 
 protected:
@@ -55,6 +57,8 @@
 
     QString m_sessionExtension;
     QString m_lastLocatedLocation;
+
+    QWidget *m_parent;
 };
 
 #endif