# HG changeset patch # User Chris Cannam # Date 1407944545 -3600 # Node ID 831188672987a0c2e6288d1cd5c34cd9d7385fcd # Parent 8bb9320f78a420033e26bc62cd0caa2588af5056 Make it possible to set the parent widget diff -r 8bb9320f78a4 -r 831188672987 widgets/InteractiveFileFinder.cpp --- 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'); diff -r 8bb9320f78a4 -r 831188672987 widgets/InteractiveFileFinder.h --- 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