[GUI] Remove code for Qt < 5.9

This commit is contained in:
Chris Hennes
2021-03-30 15:38:26 -05:00
committed by wmayer
parent 67bbb61103
commit 098d7b9aee
57 changed files with 19 additions and 686 deletions

View File

@@ -173,10 +173,6 @@ QString FileDialog::getSaveFileName (QWidget * parent, const QString & caption,
if (windowTitle.isEmpty())
windowTitle = FileDialog::tr("Save as");
#if QT_VERSION < 0x040800 && defined(FC_OS_MACOSX)
options |= QFileDialog::DontUseNativeDialog;
#endif
// NOTE: We must not change the specified file name afterwards as we may return the name of an already
// existing file. Hence we must extract the first matching suffix from the filter list and append it
// before showing the file dialog.
@@ -184,7 +180,6 @@ QString FileDialog::getSaveFileName (QWidget * parent, const QString & caption,
if (dontUseNativeDialog()) {
QList<QUrl> urls;
#if QT_VERSION >= 0x050000
options |= QFileDialog::DontUseNativeDialog;
urls << QUrl::fromLocalFile(QStandardPaths::writableLocation(QStandardPaths::DesktopLocation));
urls << QUrl::fromLocalFile(QStandardPaths::writableLocation(QStandardPaths::DocumentsLocation));
@@ -192,14 +187,6 @@ QString FileDialog::getSaveFileName (QWidget * parent, const QString & caption,
urls << QUrl::fromLocalFile(QStandardPaths::writableLocation(QStandardPaths::MusicLocation));
urls << QUrl::fromLocalFile(QStandardPaths::writableLocation(QStandardPaths::PicturesLocation));
urls << QUrl::fromLocalFile(QStandardPaths::writableLocation(QStandardPaths::MoviesLocation));
#else
urls << QUrl::fromLocalFile(QDesktopServices::storageLocation(QDesktopServices::DesktopLocation));
urls << QUrl::fromLocalFile(QDesktopServices::storageLocation(QDesktopServices::DocumentsLocation));
urls << QUrl::fromLocalFile(QDesktopServices::storageLocation(QDesktopServices::HomeLocation));
urls << QUrl::fromLocalFile(QDesktopServices::storageLocation(QDesktopServices::MusicLocation));
urls << QUrl::fromLocalFile(QDesktopServices::storageLocation(QDesktopServices::PicturesLocation));
urls << QUrl::fromLocalFile(QDesktopServices::storageLocation(QDesktopServices::MoviesLocation));
#endif
urls << QUrl::fromLocalFile(getWorkingDirectory());
urls << QUrl::fromLocalFile(restoreLocation());
urls << QUrl::fromLocalFile(QDir::currentPath());
@@ -228,9 +215,7 @@ QString FileDialog::getSaveFileName (QWidget * parent, const QString & caption,
}
else {
file = QFileDialog::getSaveFileName(parent, windowTitle, dirName, filter, selectedFilter, options);
#if QT_VERSION >= 0x040600
file = QDir::fromNativeSeparators(file);
#endif
}
if (!file.isEmpty()) {
@@ -246,9 +231,6 @@ QString FileDialog::getSaveFileName (QWidget * parent, const QString & caption,
*/
QString FileDialog::getExistingDirectory( QWidget * parent, const QString & caption, const QString & dir, Options options )
{
#if QT_VERSION < 0x040800 && defined(FC_OS_MACOSX)
options |= QFileDialog::DontUseNativeDialog;
#endif
QString path = QFileDialog::getExistingDirectory(parent, caption, dir, options);
// valid path was selected
if ( !path.isEmpty() ) {
@@ -275,15 +257,10 @@ QString FileDialog::getOpenFileName(QWidget * parent, const QString & caption, c
if (windowTitle.isEmpty())
windowTitle = FileDialog::tr("Open");
#if QT_VERSION < 0x040800 && defined(FC_OS_MACOSX)
options |= QFileDialog::DontUseNativeDialog;
#endif
QString file;
if (dontUseNativeDialog()) {
QList<QUrl> urls;
#if QT_VERSION >= 0x050000
options |= QFileDialog::DontUseNativeDialog;
urls << QUrl::fromLocalFile(QStandardPaths::writableLocation(QStandardPaths::DesktopLocation));
urls << QUrl::fromLocalFile(QStandardPaths::writableLocation(QStandardPaths::DocumentsLocation));
@@ -291,14 +268,6 @@ QString FileDialog::getOpenFileName(QWidget * parent, const QString & caption, c
urls << QUrl::fromLocalFile(QStandardPaths::writableLocation(QStandardPaths::MusicLocation));
urls << QUrl::fromLocalFile(QStandardPaths::writableLocation(QStandardPaths::PicturesLocation));
urls << QUrl::fromLocalFile(QStandardPaths::writableLocation(QStandardPaths::MoviesLocation));
#else
urls << QUrl::fromLocalFile(QDesktopServices::storageLocation(QDesktopServices::DesktopLocation));
urls << QUrl::fromLocalFile(QDesktopServices::storageLocation(QDesktopServices::DocumentsLocation));
urls << QUrl::fromLocalFile(QDesktopServices::storageLocation(QDesktopServices::HomeLocation));
urls << QUrl::fromLocalFile(QDesktopServices::storageLocation(QDesktopServices::MusicLocation));
urls << QUrl::fromLocalFile(QDesktopServices::storageLocation(QDesktopServices::PicturesLocation));
urls << QUrl::fromLocalFile(QDesktopServices::storageLocation(QDesktopServices::MoviesLocation));
#endif
urls << QUrl::fromLocalFile(getWorkingDirectory());
urls << QUrl::fromLocalFile(restoreLocation());
urls << QUrl::fromLocalFile(QDir::currentPath());
@@ -323,9 +292,7 @@ QString FileDialog::getOpenFileName(QWidget * parent, const QString & caption, c
}
else {
file = QFileDialog::getOpenFileName(parent, windowTitle, dirName, filter, selectedFilter, options);
#if QT_VERSION >= 0x040600
file = QDir::fromNativeSeparators(file);
#endif
}
if (!file.isEmpty()) {
@@ -351,15 +318,10 @@ QStringList FileDialog::getOpenFileNames (QWidget * parent, const QString & capt
if (windowTitle.isEmpty())
windowTitle = FileDialog::tr("Open");
#if QT_VERSION < 0x040800 && defined(FC_OS_MACOSX)
options |= QFileDialog::DontUseNativeDialog;
#endif
QStringList files;
if (dontUseNativeDialog()) {
QList<QUrl> urls;
#if QT_VERSION >= 0x050000
options |= QFileDialog::DontUseNativeDialog;
urls << QUrl::fromLocalFile(QStandardPaths::writableLocation(QStandardPaths::DesktopLocation));
urls << QUrl::fromLocalFile(QStandardPaths::writableLocation(QStandardPaths::DocumentsLocation));
@@ -367,14 +329,6 @@ QStringList FileDialog::getOpenFileNames (QWidget * parent, const QString & capt
urls << QUrl::fromLocalFile(QStandardPaths::writableLocation(QStandardPaths::MusicLocation));
urls << QUrl::fromLocalFile(QStandardPaths::writableLocation(QStandardPaths::PicturesLocation));
urls << QUrl::fromLocalFile(QStandardPaths::writableLocation(QStandardPaths::MoviesLocation));
#else
urls << QUrl::fromLocalFile(QDesktopServices::storageLocation(QDesktopServices::DesktopLocation));
urls << QUrl::fromLocalFile(QDesktopServices::storageLocation(QDesktopServices::DocumentsLocation));
urls << QUrl::fromLocalFile(QDesktopServices::storageLocation(QDesktopServices::HomeLocation));
urls << QUrl::fromLocalFile(QDesktopServices::storageLocation(QDesktopServices::MusicLocation));
urls << QUrl::fromLocalFile(QDesktopServices::storageLocation(QDesktopServices::PicturesLocation));
urls << QUrl::fromLocalFile(QDesktopServices::storageLocation(QDesktopServices::MoviesLocation));
#endif
urls << QUrl::fromLocalFile(getWorkingDirectory());
urls << QUrl::fromLocalFile(restoreLocation());
urls << QUrl::fromLocalFile(QDir::currentPath());
@@ -399,11 +353,9 @@ QStringList FileDialog::getOpenFileNames (QWidget * parent, const QString & capt
}
else {
files = QFileDialog::getOpenFileNames(parent, windowTitle, dirName, filter, selectedFilter, options);
#if QT_VERSION >= 0x040600
for (QStringList::iterator it = files.begin(); it != files.end(); ++it) {
*it = QDir::fromNativeSeparators(*it);
}
#endif
}
if (!files.isEmpty()) {
@@ -483,9 +435,7 @@ FileOptionsDialog::FileOptionsDialog( QWidget* parent, Qt::WindowFlags fl )
extensionButton = new QPushButton( this );
extensionButton->setText( tr( "Extended" ) );
#if QT_VERSION >= 0x050000
setOption(QFileDialog::DontUseNativeDialog);
#endif
// This is an alternative to add the button to the grid layout
//QDialogButtonBox* box = this->findChild<QDialogButtonBox*>();
@@ -493,11 +443,7 @@ FileOptionsDialog::FileOptionsDialog( QWidget* parent, Qt::WindowFlags fl )
//search for the grid layout and add the new button
QGridLayout* grid = this->findChild<QGridLayout*>();
#if QT_VERSION >= 0x040500
grid->addWidget(extensionButton, 4, 2, Qt::AlignLeft);
#else
grid->addWidget(extensionButton, 4, 5, Qt::AlignLeft);
#endif
connect(extensionButton, SIGNAL(clicked()), this, SLOT(toggleExtension()));
}