summaryrefslogtreecommitdiffstats
path: root/src/widgets/dialogs
diff options
context:
space:
mode:
Diffstat (limited to 'src/widgets/dialogs')
-rw-r--r--src/widgets/dialogs/qfiledialog.cpp32
-rw-r--r--src/widgets/dialogs/qfilesystemmodel.cpp14
-rw-r--r--src/widgets/dialogs/qfilesystemmodel_p.h3
-rw-r--r--src/widgets/dialogs/qmessagebox.cpp4
-rw-r--r--src/widgets/dialogs/qwizard.cpp6
5 files changed, 40 insertions, 19 deletions
diff --git a/src/widgets/dialogs/qfiledialog.cpp b/src/widgets/dialogs/qfiledialog.cpp
index 3152a8dd3e..5f5b325785 100644
--- a/src/widgets/dialogs/qfiledialog.cpp
+++ b/src/widgets/dialogs/qfiledialog.cpp
@@ -161,9 +161,10 @@ Q_GLOBAL_STATIC(QUrl, lastVisitedDir)
By default, a platform-native file dialog will be used if the platform has
one. In that case, the widgets which would otherwise be used to construct the
dialog will not be instantiated, so related accessors such as layout() and
- itemDelegate() will return null. You can set the \l DontUseNativeDialog option to
- ensure that the widget-based implementation will be used instead of the
- native dialog.
+ itemDelegate() will return null. Also, not all platforms show file dialogs
+ with a title bar, so be aware that the caption text might not be visible to
+ the user. You can set the \l DontUseNativeDialog option to ensure that the
+ widget-based implementation will be used instead of the native dialog.
\sa QDir, QFileInfo, QFile, QColorDialog, QFontDialog, {Standard Dialogs Example},
{Application Example}
@@ -1256,8 +1257,9 @@ QStringList QFileDialogPrivate::addDefaultSuffixToFiles(const QStringList &files
QFileInfo info(name);
// if the filename has no suffix, add the default suffix
const QString defaultSuffix = options->defaultSuffix();
- if (!defaultSuffix.isEmpty() && !info.isDir() && name.lastIndexOf(QLatin1Char('.')) == -1)
+ if (!defaultSuffix.isEmpty() && !info.isDir() && !info.fileName().contains(u'.'))
name += QLatin1Char('.') + defaultSuffix;
+
if (info.isAbsolute()) {
files.append(name);
} else {
@@ -1283,8 +1285,12 @@ QList<QUrl> QFileDialogPrivate::addDefaultSuffixToUrls(const QList<QUrl> &urlsTo
QUrl url = urlsToFix.at(i);
// if the filename has no suffix, add the default suffix
const QString defaultSuffix = options->defaultSuffix();
- if (!defaultSuffix.isEmpty() && !url.path().endsWith(QLatin1Char('/')) && url.path().lastIndexOf(QLatin1Char('.')) == -1)
- url.setPath(url.path() + QLatin1Char('.') + defaultSuffix);
+ if (!defaultSuffix.isEmpty()) {
+ const QString urlPath = url.path();
+ const auto idx = urlPath.lastIndexOf(u'/');
+ if (idx != (urlPath.size() - 1) && !QStringView{urlPath}.mid(idx + 1).contains(u'.'))
+ url.setPath(urlPath + u'.' + defaultSuffix);
+ }
urls.append(url);
}
return urls;
@@ -2183,7 +2189,8 @@ QString QFileDialog::labelText(DialogLabel label) const
then a default caption will be used.
On Windows, and \macos, this static function will use the
- native file dialog and not a QFileDialog.
+ native file dialog and not a QFileDialog. Note that the \macos native file
+ dialog does not show a title bar.
On Windows the dialog will spin a blocking modal event loop that will not
dispatch any QTimers, and if \a parent is not \nullptr then it will position
@@ -2294,7 +2301,8 @@ QUrl QFileDialog::getOpenFileUrl(QWidget *parent,
then a default caption will be used.
On Windows, and \macos, this static function will use the
- native file dialog and not a QFileDialog.
+ native file dialog and not a QFileDialog. Note that the \macos native file
+ dialog does not show a title bar.
On Windows the dialog will spin a blocking modal event loop that will not
dispatch any QTimers, and if \a parent is not \nullptr then it will position
@@ -2447,7 +2455,7 @@ void QFileDialog::getOpenFileContent(const QString &nameFilter, const std::funct
#else
QFileDialog *dialog = new QFileDialog();
dialog->setFileMode(QFileDialog::ExistingFile);
- dialog->selectNameFilter(nameFilter);
+ dialog->setNameFilter(nameFilter);
auto fileSelected = [=](const QString &fileName) {
QByteArray fileContent;
@@ -2461,7 +2469,7 @@ void QFileDialog::getOpenFileContent(const QString &nameFilter, const std::funct
auto dialogClosed = [=](int code) {
Q_UNUSED(code);
- delete dialog;
+ dialog->deleteLater();
};
connect(dialog, &QFileDialog::fileSelected, fileSelected);
@@ -2506,7 +2514,7 @@ void QFileDialog::saveFileContent(const QByteArray &fileContent, const QString &
auto dialogClosed = [=](int code) {
Q_UNUSED(code);
- delete dialog;
+ dialog->deleteLater();
};
connect(dialog, &QFileDialog::fileSelected, fileSelected);
@@ -2659,6 +2667,8 @@ QUrl QFileDialog::getSaveFileUrl(QWidget *parent,
to pass \l{QFileDialog::}{DontUseNativeDialog} to display files using a
QFileDialog.
+ Note that the \macos native file dialog does not show a title bar.
+
On Unix/X11, the normal behavior of the file dialog is to resolve and
follow symlinks. For example, if \c{/usr/tmp} is a symlink to \c{/var/tmp},
the file dialog will change to \c{/var/tmp} after entering \c{/usr/tmp}. If
diff --git a/src/widgets/dialogs/qfilesystemmodel.cpp b/src/widgets/dialogs/qfilesystemmodel.cpp
index 0db06e9b71..1d23ffaadc 100644
--- a/src/widgets/dialogs/qfilesystemmodel.cpp
+++ b/src/widgets/dialogs/qfilesystemmodel.cpp
@@ -397,8 +397,11 @@ QFileSystemModelPrivate::QFileSystemNode *QFileSystemModelPrivate::node(const QS
if (absolutePath.endsWith(QLatin1Char('/')))
trailingSeparator = QLatin1String("\\");
int r = 0;
- QFileSystemModelPrivate::QFileSystemNode *rootNode = const_cast<QFileSystemModelPrivate::QFileSystemNode*>(&root);
- if (!root.children.contains(host.toLower())) {
+ auto rootNode = const_cast<QFileSystemModelPrivate::QFileSystemNode*>(&root);
+ auto it = root.children.constFind(host);
+ if (it != root.children.cend()) {
+ host = it.key(); // Normalize case for lookup in visibleLocation()
+ } else {
if (pathElements.count() == 1 && !absolutePath.endsWith(QLatin1Char('/')))
return rootNode;
QFileInfo info(host);
@@ -723,6 +726,9 @@ QVariant QFileSystemModel::data(const QModelIndex &index, int role) const
switch (role) {
case Qt::EditRole:
+ if (index.column() == 0)
+ return d->name(index);
+ Q_FALLTHROUGH();
case Qt::DisplayRole:
switch (index.column()) {
case 0: return d->displayName(index);
@@ -2057,6 +2063,10 @@ QStringList QFileSystemModelPrivate::unwatchPathsAt(const QModelIndex &index)
}
#endif // filesystemwatcher && Q_OS_WIN
+QFileSystemModelPrivate::QFileSystemModelPrivate() = default;
+
+QFileSystemModelPrivate::~QFileSystemModelPrivate() = default;
+
/*!
\internal
*/
diff --git a/src/widgets/dialogs/qfilesystemmodel_p.h b/src/widgets/dialogs/qfilesystemmodel_p.h
index ad98b9ef44..0eec870016 100644
--- a/src/widgets/dialogs/qfilesystemmodel_p.h
+++ b/src/widgets/dialogs/qfilesystemmodel_p.h
@@ -213,7 +213,8 @@ public:
bool isVisible = false;
};
- QFileSystemModelPrivate() = default;
+ QFileSystemModelPrivate();
+ ~QFileSystemModelPrivate();
void init();
/*
\internal
diff --git a/src/widgets/dialogs/qmessagebox.cpp b/src/widgets/dialogs/qmessagebox.cpp
index 4e7a4a65e3..8aaab72239 100644
--- a/src/widgets/dialogs/qmessagebox.cpp
+++ b/src/widgets/dialogs/qmessagebox.cpp
@@ -1894,7 +1894,7 @@ void QMessageBox::aboutQt(QWidget *parent, const QString &title)
"<p>Qt and the Qt logo are trademarks of The Qt Company Ltd.</p>"
"<p>Qt is The Qt Company Ltd product developed as an open source "
"project. See <a href=\"http://%3/\">%3</a> for more information.</p>"
- ).arg(QStringLiteral("2020"),
+ ).arg(QStringLiteral("2022"),
QStringLiteral("qt.io/licensing"),
QStringLiteral("qt.io"));
QMessageBox *msgBox = new QMessageBox(parent);
@@ -2046,7 +2046,7 @@ int QMessageBoxPrivate::showOldMessageBox(QWidget *parent, QMessageBox::Icon ico
void QMessageBoxPrivate::retranslateStrings()
{
#if QT_CONFIG(textedit)
- if (detailsButton)
+ if (detailsButton && detailsText)
detailsButton->setLabel(detailsText->isHidden() ? ShowLabel : HideLabel);
#endif
}
diff --git a/src/widgets/dialogs/qwizard.cpp b/src/widgets/dialogs/qwizard.cpp
index 00c5d5d426..d1639de232 100644
--- a/src/widgets/dialogs/qwizard.cpp
+++ b/src/widgets/dialogs/qwizard.cpp
@@ -256,11 +256,11 @@ public:
bool extension = false;
bool sideWidget = false;
- bool operator==(const QWizardLayoutInfo &other);
- inline bool operator!=(const QWizardLayoutInfo &other) { return !operator==(other); }
+ bool operator==(const QWizardLayoutInfo &other) const;
+ inline bool operator!=(const QWizardLayoutInfo &other) const { return !operator==(other); }
};
-bool QWizardLayoutInfo::operator==(const QWizardLayoutInfo &other)
+bool QWizardLayoutInfo::operator==(const QWizardLayoutInfo &other) const
{
return topLevelMarginLeft == other.topLevelMarginLeft
&& topLevelMarginRight == other.topLevelMarginRight