Changeset 51939 in vbox
- Timestamp:
- Jul 8, 2014 5:25:27 PM (10 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Frontends/VirtualBox/src/extensions/QIFileDialog.cpp
r45437 r51939 345 345 #elif defined (Q_WS_MAC) && (QT_VERSION >= 0x040600) 346 346 347 /* After 4.5 exec ignores the Qt::Sheet flag. See "New Ways of Using 348 * Dialogs" in http://doc.trolltech.com/qq/QtQuarterly30.pdf why. Because 349 * we are lazy, we recreate the old behavior. Unfortunately there is a bug 350 * in Qt 4.5.x which result in showing the native & the Qt dialog at the 351 * same time. */ 352 QFileDialog dlg (aParent, Qt::Sheet); 353 dlg.setWindowTitle (aCaption); 354 dlg.setDirectory (aDir); 355 dlg.setResolveSymlinks (aResolveSymlinks); 356 dlg.setFileMode (aDirOnly ? QFileDialog::DirectoryOnly : QFileDialog::Directory); 347 /* After 4.5 exec ignores the Qt::Sheet flag. 348 * See "New Ways of Using Dialogs" in http://doc.trolltech.com/qq/QtQuarterly30.pdf why. 349 * We want the old behavior for file-save dialog. Unfortunately there is a bug in Qt 4.5.x 350 * which result in showing the native & the Qt dialog at the same time. */ 351 QFileDialog dlg(aParent); 352 dlg.setWindowTitle(aCaption); 353 dlg.setDirectory(aDir); 354 dlg.setResolveSymlinks(aResolveSymlinks); 355 dlg.setFileMode(aDirOnly ? QFileDialog::DirectoryOnly : QFileDialog::Directory); 357 356 358 357 QEventLoop eventLoop; 359 358 QObject::connect(&dlg, SIGNAL(finished(int)), 360 359 &eventLoop, SLOT(quit())); 361 /* Use the new open call. */362 360 dlg.open(); 363 361 eventLoop.exec(); 364 362 365 return dlg.result() == QDialog::Accepted ? dlg.selectedFiles() [0] : QString::null;363 return dlg.result() == QDialog::Accepted ? dlg.selectedFiles().value(0, QString()) : QString(); 366 364 367 365 #else … … 568 566 #elif defined (Q_WS_MAC) && (QT_VERSION >= 0x040600) 569 567 570 /* After 4.5 exec ignores the Qt::Sheet flag. See "New Ways of Using 571 * Dialogs" in http://doc.trolltech.com/qq/QtQuarterly30.pdf why. Because 572 * we are lazy, we recreate the old behavior. Unfortunately there is a bug 573 * in Qt 4.5.x which result in showing the native & the Qt dialog at the 574 * same time. */ 575 QFileDialog dlg (aParent); 576 dlg.setWindowTitle (aCaption); 577 dlg.setDirectory (aStartWith); 578 dlg.setFilter (aFilters); 579 dlg.setFileMode (QFileDialog::QFileDialog::AnyFile); 580 dlg.setAcceptMode (QFileDialog::AcceptSave); 568 /* After 4.5 exec ignores the Qt::Sheet flag. 569 * See "New Ways of Using Dialogs" in http://doc.trolltech.com/qq/QtQuarterly30.pdf why. 570 * We want the old behavior for file-save dialog. Unfortunately there is a bug in Qt 4.5.x 571 * which result in showing the native & the Qt dialog at the same time. */ 572 QFileDialog dlg(aParent); 573 dlg.setWindowTitle(aCaption); 574 575 /* Some predictive algorithm which seems missed in native code. */ 576 QDir dir(aStartWith); 577 while (!dir.isRoot() && !dir.exists()) 578 dir = QDir(QFileInfo(dir.absolutePath()).absolutePath()); 579 const QString strDirectory = dir.absolutePath(); 580 if (!strDirectory.isNull()) 581 dlg.setDirectory(strDirectory); 582 if (strDirectory != aStartWith) 583 dlg.selectFile(QFileInfo(aStartWith).absoluteFilePath()); 584 585 dlg.setNameFilter(aFilters); 586 dlg.setFileMode(QFileDialog::AnyFile); 587 dlg.setAcceptMode(QFileDialog::AcceptSave); 581 588 if (aSelectedFilter) 582 dlg.selectFilter (*aSelectedFilter);583 dlg.setResolveSymlinks (aResolveSymlinks);584 dlg.setConfirmOverwrite (fConfirmOverwrite);589 dlg.selectFilter(*aSelectedFilter); 590 dlg.setResolveSymlinks(aResolveSymlinks); 591 dlg.setConfirmOverwrite(fConfirmOverwrite); 585 592 586 593 QEventLoop eventLoop; 587 594 QObject::connect(&dlg, SIGNAL(finished(int)), 588 595 &eventLoop, SLOT(quit())); 589 /* Use the new open call. */590 596 dlg.open(); 591 597 eventLoop.exec(); 592 598 593 return dlg.result() == QDialog::Accepted ? dlg.selectedFiles().value (0, "") : QString::null;599 return dlg.result() == QDialog::Accepted ? dlg.selectedFiles().value(0, QString()) : QString(); 594 600 595 601 #else … … 817 823 #elif defined (Q_WS_MAC) && (QT_VERSION >= 0x040600) 818 824 819 /* After 4.5 exec ignores the Qt::Sheet flag. See "New Ways of Using 820 * Dialogs" in http://doc.trolltech.com/qq/QtQuarterly30.pdf why. Because 821 * we are lazy, we recreate the old behavior. Unfortunately there is a bug 822 * in Qt 4.5.x which result in showing the native & the Qt dialog at the 823 * same time. */ 824 QFileDialog dlg (aParent, Qt::Sheet); 825 dlg.setWindowTitle (aCaption); 826 dlg.setDirectory (aStartWith); 827 dlg.setNameFilter (aFilters); 825 /* After 4.5 exec ignores the Qt::Sheet flag. 826 * See "New Ways of Using Dialogs" in http://doc.trolltech.com/qq/QtQuarterly30.pdf why. 827 * We want the old behavior for file-save dialog. Unfortunately there is a bug in Qt 4.5.x 828 * which result in showing the native & the Qt dialog at the same time. */ 829 QFileDialog dlg(aParent); 830 dlg.setWindowTitle(aCaption); 831 832 /* Some predictive algorithm which seems missed in native code. */ 833 QDir dir(aStartWith); 834 while (!dir.isRoot() && !dir.exists()) 835 dir = QDir(QFileInfo(dir.absolutePath()).absolutePath()); 836 const QString strDirectory = dir.absolutePath(); 837 if (!strDirectory.isNull()) 838 dlg.setDirectory(strDirectory); 839 if (strDirectory != aStartWith) 840 dlg.selectFile(QFileInfo(aStartWith).absoluteFilePath()); 841 842 dlg.setNameFilter(aFilters); 828 843 if (aSingleFile) 829 dlg.setFileMode (QFileDialog::ExistingFile);844 dlg.setFileMode(QFileDialog::ExistingFile); 830 845 else 831 dlg.setFileMode (QFileDialog::ExistingFiles);846 dlg.setFileMode(QFileDialog::ExistingFiles); 832 847 if (aSelectedFilter) 833 dlg.selectFilter (*aSelectedFilter);834 dlg.setResolveSymlinks (aResolveSymlinks);848 dlg.selectFilter(*aSelectedFilter); 849 dlg.setResolveSymlinks(aResolveSymlinks); 835 850 836 851 QEventLoop eventLoop; 837 852 QObject::connect(&dlg, SIGNAL(finished(int)), 838 853 &eventLoop, SLOT(quit())); 839 /* Use the new open call. */840 854 dlg.open(); 841 855 eventLoop.exec(); 842 856 843 return dlg.result() == QDialog::Accepted ? dlg.selectedFiles() : QStringList() << QString ::null;857 return dlg.result() == QDialog::Accepted ? dlg.selectedFiles() : QStringList() << QString(); 844 858 845 859 #else
Note:
See TracChangeset
for help on using the changeset viewer.

