Silently strip leading dot off QFileDialog default suffixes.
Change-Id: Ie41fafe8c2ce7e8ac8dd595ca3809c1da3b386f4 Reviewed-by: Olivier Goffart <ogoffart@woboq.com> Reviewed-by: Shawn Rutledge <shawn.rutledge@digia.com>
This commit is contained in:
parent
b88b09fb16
commit
d934ddc297
2
dist/changes-5.2.0
vendored
2
dist/changes-5.2.0
vendored
@ -29,3 +29,5 @@ QtWidgets
|
|||||||
- [QTBUG-4206] QTableView resizeToContents will now adjust to actual contents
|
- [QTBUG-4206] QTableView resizeToContents will now adjust to actual contents
|
||||||
and not just visible area. QHeaderView::setAutoResizePrecision() has been
|
and not just visible area. QHeaderView::setAutoResizePrecision() has been
|
||||||
introduced to control how precise the autoResize should be.
|
introduced to control how precise the autoResize should be.
|
||||||
|
|
||||||
|
- QFileDialog::setDefaultSuffix() removes leading dot characters.
|
||||||
|
@ -495,6 +495,8 @@ QStringList QFileDialogOptions::nameFilters() const
|
|||||||
void QFileDialogOptions::setDefaultSuffix(const QString &suffix)
|
void QFileDialogOptions::setDefaultSuffix(const QString &suffix)
|
||||||
{
|
{
|
||||||
d->defaultSuffix = suffix;
|
d->defaultSuffix = suffix;
|
||||||
|
if (d->defaultSuffix.size() > 1 && d->defaultSuffix.startsWith(QLatin1Char('.')))
|
||||||
|
d->defaultSuffix.remove(0, 1); // Silently change ".txt" -> "txt".
|
||||||
}
|
}
|
||||||
|
|
||||||
QString QFileDialogOptions::defaultSuffix() const
|
QString QFileDialogOptions::defaultSuffix() const
|
||||||
|
@ -1552,6 +1552,8 @@ bool QFileDialog::confirmOverwrite() const
|
|||||||
filename if it has no suffix already. The suffix is typically
|
filename if it has no suffix already. The suffix is typically
|
||||||
used to indicate the file type (e.g. "txt" indicates a text
|
used to indicate the file type (e.g. "txt" indicates a text
|
||||||
file).
|
file).
|
||||||
|
|
||||||
|
If the first character is a dot ('.'), it is removed.
|
||||||
*/
|
*/
|
||||||
void QFileDialog::setDefaultSuffix(const QString &suffix)
|
void QFileDialog::setDefaultSuffix(const QString &suffix)
|
||||||
{
|
{
|
||||||
|
@ -621,6 +621,8 @@ void tst_QFiledialog::defaultSuffix()
|
|||||||
QCOMPARE(fd.defaultSuffix(), QString());
|
QCOMPARE(fd.defaultSuffix(), QString());
|
||||||
fd.setDefaultSuffix("txt");
|
fd.setDefaultSuffix("txt");
|
||||||
QCOMPARE(fd.defaultSuffix(), QString("txt"));
|
QCOMPARE(fd.defaultSuffix(), QString("txt"));
|
||||||
|
fd.setDefaultSuffix(".txt");
|
||||||
|
QCOMPARE(fd.defaultSuffix(), QString("txt"));
|
||||||
fd.setDefaultSuffix(QString());
|
fd.setDefaultSuffix(QString());
|
||||||
QCOMPARE(fd.defaultSuffix(), QString());
|
QCOMPARE(fd.defaultSuffix(), QString());
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user