I admit that I also like the native system window, so I played around with simple filtering and in Windows it works.
I know that `QFileDialog::DontUseNativeDialog` is safer, but let's be honest: how many people are going to type in the graphics link instead of pointing to the appropriate file from disk?
Such code works for me.
So I leave the condition only Q_OS_MAC and check the beginning of the path. If http/https then I display a message, but with no crash.
Code:
QFileDialog::Options options = QFileDialog::Options();
#if defined(Q_OS_MAC)
options = options | QFileDialog::DontUseNativeDialog;
#endif
// tempfilepaths are full absolute file paths to the files to be added
QStringList tempfilepaths = QFileDialog::getOpenFileNames(this,
tr("Add Existing Files"),
m_LastFolderOpen,
filter_string,
NULL,
options);
QStringList filepaths;
for (const QString &path : tempfilepaths) {
if (path.startsWith("http://", Qt::CaseInsensitive)
|| path.startsWith("https://", Qt::CaseInsensitive)) {
Utility::DisplayStdErrorDialog(
tr("The path \"%1\" is not a local file and was not added.").arg(path));
continue;
}
filepaths << path;
}
Such a preliminary check of the existence of links should be enough, and Windows users will not turn their noses up at the default Qt window.