summaryrefslogtreecommitdiffstats
path: root/src/widgets/dialogs
diff options
context:
space:
mode:
Diffstat (limited to 'src/widgets/dialogs')
-rw-r--r--src/widgets/dialogs/qcolordialog.cpp15
-rw-r--r--src/widgets/dialogs/qdialog.cpp37
-rw-r--r--src/widgets/dialogs/qdialog.h15
-rw-r--r--src/widgets/dialogs/qfiledialog.cpp157
-rw-r--r--src/widgets/dialogs/qfiledialog.h25
-rw-r--r--src/widgets/dialogs/qfiledialog_p.h10
-rw-r--r--src/widgets/dialogs/qfontdialog.cpp2
-rw-r--r--src/widgets/dialogs/qmessagebox.cpp16
-rw-r--r--src/widgets/dialogs/qmessagebox.h4
-rw-r--r--src/widgets/dialogs/qprogressdialog.cpp10
-rw-r--r--src/widgets/dialogs/qsidebar.cpp2
-rw-r--r--src/widgets/dialogs/qwizard.cpp26
-rw-r--r--src/widgets/dialogs/qwizard_win_p.h2
13 files changed, 236 insertions, 85 deletions
diff --git a/src/widgets/dialogs/qcolordialog.cpp b/src/widgets/dialogs/qcolordialog.cpp
index 7132bb3297..c0bacd553d 100644
--- a/src/widgets/dialogs/qcolordialog.cpp
+++ b/src/widgets/dialogs/qcolordialog.cpp
@@ -646,7 +646,7 @@ void QColorWell::mouseMoveEvent(QMouseEvent *e)
drg->setMimeData(mime);
drg->setPixmap(pix);
mousePressed = false;
- drg->start();
+ drg->exec(Qt::CopyAction);
}
#endif
}
@@ -842,8 +842,8 @@ void QColorLuminancePicker::paintEvent(QPaintEvent *)
p.drawPixmap(1, coff, *pix);
const QPalette &g = palette();
qDrawShadePanel(&p, r, g, true);
- p.setPen(g.foreground().color());
- p.setBrush(g.foreground());
+ p.setPen(g.windowText().color());
+ p.setBrush(g.windowText());
QPolygon a;
int y = val2y(val);
a.setPoints(3, w, y, w+5, y+5, w+5, y-5);
@@ -1131,7 +1131,7 @@ void QColorShowLabel::mouseMoveEvent(QMouseEvent *e)
drg->setMimeData(mime);
drg->setPixmap(pix);
mousePressed = false;
- drg->start();
+ drg->exec(Qt::CopyAction);
}
#endif
}
@@ -1179,7 +1179,8 @@ QColorShower::QColorShower(QColorDialog *parent)
curQColor = Qt::white;
gl = new QGridLayout(this);
- gl->setMargin(gl->spacing());
+ const int s = gl->spacing();
+ gl->setContentsMargins(s, s, s, s);
lab = new QColorShowLabel(this);
#ifdef QT_SMALL_COLORDIALOG
@@ -1807,7 +1808,7 @@ void QColorDialogPrivate::initWidgets()
rightLay->addStretch();
cs = new QColorShower(q);
- pickLay->setMargin(cs->gl->margin());
+ pickLay->setContentsMargins(cs->gl->contentsMargins());
QObject::connect(cs, SIGNAL(newCol(QRgb)), q, SLOT(_q_newColorTypedIn(QRgb)));
QObject::connect(cs, SIGNAL(currentColorChanged(QColor)),
q, SIGNAL(currentColorChanged(QColor)));
@@ -1816,7 +1817,7 @@ void QColorDialogPrivate::initWidgets()
#else
rightLay->addWidget(cs);
if (leftLay)
- leftLay->addSpacing(cs->gl->margin());
+ leftLay->addSpacing(cs->gl->contentsMargins().right());
#endif
buttons = new QDialogButtonBox(q);
diff --git a/src/widgets/dialogs/qdialog.cpp b/src/widgets/dialogs/qdialog.cpp
index 1c10e3e786..caab6c16ba 100644
--- a/src/widgets/dialogs/qdialog.cpp
+++ b/src/widgets/dialogs/qdialog.cpp
@@ -148,7 +148,7 @@ bool QDialogPrivate::canBeNativeDialog() const
/*!
\internal
- Properly hides dialog and sets the \p resultCode
+ Properly hides dialog and sets the \a resultCode.
*/
void QDialogPrivate::hide(int resultCode)
{
@@ -164,8 +164,8 @@ void QDialogPrivate::hide(int resultCode)
/*!
\internal
- Emits finished() signal with \p resultCode. If the \p dialogCode
- is equal to 0 emits rejected(), if the \p dialogCode is equal to
+ Emits finished() signal with \a resultCode. If the \a dialogCode
+ is equal to 0 emits rejected(), if the \a dialogCode is equal to
1 emits accepted().
*/
void QDialogPrivate::finalize(int resultCode, int dialogCode)
@@ -429,7 +429,7 @@ QDialog::~QDialog()
/*!
\internal
This function is called by the push button \a pushButton when it
- becomes the default button. If \a pushButton is 0, the dialogs
+ becomes the default button. If \a pushButton is \nullptr, the dialogs
default default button becomes the default button. This is what a
push button calls when it loses focus.
*/
@@ -767,12 +767,31 @@ void QDialog::setVisible(bool visible)
if (!testAttribute(Qt::WA_DontShowOnScreen) && d->canBeNativeDialog() && d->setNativeDialogVisible(visible))
return;
+ // We should not block windows by the invisible modal dialog
+ // if a platform-specific dialog is implemented as an in-process
+ // Qt window, because in this case it will also be blocked.
+ const bool dontBlockWindows = testAttribute(Qt::WA_DontShowOnScreen)
+ && d->styleHint(QPlatformDialogHelper::DialogIsQtWindow).toBool();
+ Qt::WindowModality oldModality;
+ bool wasModalitySet;
+
+ if (dontBlockWindows) {
+ oldModality = windowModality();
+ wasModalitySet = testAttribute(Qt::WA_SetWindowModality);
+ setWindowModality(Qt::NonModal);
+ }
+
if (visible) {
if (testAttribute(Qt::WA_WState_ExplicitShowHide) && !testAttribute(Qt::WA_WState_Hidden))
return;
QWidget::setVisible(visible);
+#if QT_DEPRECATED_SINCE(5, 13)
+QT_WARNING_PUSH
+QT_WARNING_DISABLE_DEPRECATED
showExtension(d->doShowExtension);
+QT_WARNING_POP
+#endif
QWidget *fw = window()->focusWidget();
if (!fw)
fw = this;
@@ -833,6 +852,11 @@ void QDialog::setVisible(bool visible)
d->eventLoop->exit();
}
+ if (dontBlockWindows) {
+ setWindowModality(oldModality);
+ setAttribute(Qt::WA_SetWindowModality, wasModalitySet);
+ }
+
#if QT_CONFIG(pushbutton)
const QPlatformTheme *theme = QGuiApplicationPrivate::platformTheme();
if (d->mainDef && isActiveWindow()
@@ -934,6 +958,7 @@ void QDialog::adjustPosition(QWidget* w)
move(p);
}
+#if QT_DEPRECATED_SINCE(5, 13)
/*!
\obsolete
@@ -1002,7 +1027,7 @@ void QDialog::setExtension(QWidget* extension)
/*!
\obsolete
- Returns the dialog's extension or 0 if no extension has been
+ Returns the dialog's extension or \nullptr if no extension has been
defined.
Instead of using this functionality, we recommend that you simply call
@@ -1078,7 +1103,7 @@ void QDialog::showExtension(bool showIt)
#endif
}
}
-
+#endif
/*! \reimp */
QSize QDialog::sizeHint() const
diff --git a/src/widgets/dialogs/qdialog.h b/src/widgets/dialogs/qdialog.h
index 7f267dd939..ce2194a1de 100644
--- a/src/widgets/dialogs/qdialog.h
+++ b/src/widgets/dialogs/qdialog.h
@@ -69,11 +69,12 @@ public:
void setVisible(bool visible) override;
- void setOrientation(Qt::Orientation orientation);
- Qt::Orientation orientation() const;
-
- void setExtension(QWidget* extension);
- QWidget* extension() const;
+#if QT_DEPRECATED_SINCE(5, 13)
+ QT_DEPRECATED_X("Use show/hide on the affected widget instead") void setOrientation(Qt::Orientation orientation);
+ QT_DEPRECATED_X("Use show/hide on the affected widget instead") Qt::Orientation orientation() const;
+ QT_DEPRECATED_X("Use show/hide on the affected widget instead") void setExtension(QWidget* extension);
+ QT_DEPRECATED_X("Use show/hide on the affected widget instead") QWidget* extension() const;
+#endif
QSize sizeHint() const override;
QSize minimumSizeHint() const override;
@@ -96,7 +97,9 @@ public Q_SLOTS:
virtual void accept();
virtual void reject();
- void showExtension(bool);
+#if QT_DEPRECATED_SINCE(5, 13)
+ QT_DEPRECATED_X("Use show/hide on the affected widget instead") void showExtension(bool);
+#endif
protected:
QDialog(QDialogPrivate &, QWidget *parent, Qt::WindowFlags f = Qt::WindowFlags());
diff --git a/src/widgets/dialogs/qfiledialog.cpp b/src/widgets/dialogs/qfiledialog.cpp
index eb3479b3e0..f772eb1241 100644
--- a/src/widgets/dialogs/qfiledialog.cpp
+++ b/src/widgets/dialogs/qfiledialog.cpp
@@ -73,6 +73,9 @@
#elif defined(Q_OS_WIN)
# include <QtCore/qt_windows.h>
#endif
+#if defined(Q_OS_WASM)
+#include <private/qwasmlocalfileaccess_p.h>
+#endif
QT_BEGIN_NAMESPACE
@@ -584,10 +587,13 @@ void QFileDialogPrivate::retranslateWindowTitle()
return;
if (q->acceptMode() == QFileDialog::AcceptOpen) {
const QFileDialog::FileMode fileMode = q->fileMode();
+QT_WARNING_PUSH
+QT_WARNING_DISABLE_DEPRECATED
if (fileMode == QFileDialog::DirectoryOnly || fileMode == QFileDialog::Directory)
q->setWindowTitle(QFileDialog::tr("Find Directory"));
else
q->setWindowTitle(QFileDialog::tr("Open"));
+QT_WARNING_POP
} else
q->setWindowTitle(QFileDialog::tr("Save As"));
@@ -611,7 +617,10 @@ void QFileDialogPrivate::updateFileNameLabel()
setLabelTextControl(QFileDialog::FileName, options->labelText(QFileDialogOptions::FileName));
} else {
switch (q_func()->fileMode()) {
+QT_WARNING_PUSH
+QT_WARNING_DISABLE_DEPRECATED
case QFileDialog::DirectoryOnly:
+QT_WARNING_POP
case QFileDialog::Directory:
setLabelTextControl(QFileDialog::FileName, QFileDialog::tr("Directory:"));
break;
@@ -639,7 +648,10 @@ void QFileDialogPrivate::updateOkButtonText(bool saveAsOnFolder)
return;
} else {
switch (q->fileMode()) {
+QT_WARNING_PUSH
+QT_WARNING_DISABLE_DEPRECATED
case QFileDialog::DirectoryOnly:
+QT_WARNING_POP
case QFileDialog::Directory:
setLabelTextControl(QFileDialog::Accept, QFileDialog::tr("&Choose"));
break;
@@ -1359,6 +1371,7 @@ void QFileDialog::setNameFilter(const QString &filter)
}
+#if QT_DEPRECATED_SINCE(5, 13)
/*!
\property QFileDialog::nameFilterDetailsVisible
\obsolete
@@ -1380,6 +1393,7 @@ bool QFileDialog::isNameFilterDetailsVisible() const
{
return !testOption(HideNameFilterDetails);
}
+#endif
/*
@@ -1704,7 +1718,10 @@ void QFileDialog::setFileMode(QFileDialog::FileMode mode)
d->options->setFileMode(static_cast<QFileDialogOptions::FileMode>(mode));
// keep ShowDirsOnly option in sync with fileMode (BTW, DirectoryOnly is obsolete)
+QT_WARNING_PUSH
+QT_WARNING_DISABLE_DEPRECATED
setOption(ShowDirsOnly, mode == DirectoryOnly);
+QT_WARNING_POP
if (!d->usingWidgets())
return;
@@ -1722,11 +1739,14 @@ void QFileDialog::setFileMode(QFileDialog::FileMode mode)
// set filter
d->model->setFilter(d->filterForMode(filter()));
// setup file type for directory
+QT_WARNING_PUSH
+QT_WARNING_DISABLE_DEPRECATED
if (mode == DirectoryOnly || mode == Directory) {
d->qFileDialogUi->fileTypeCombo->clear();
d->qFileDialogUi->fileTypeCombo->addItem(tr("Directories"));
d->qFileDialogUi->fileTypeCombo->setEnabled(false);
}
+QT_WARNING_POP
d->updateFileNameLabel();
d->updateOkButtonText();
d->qFileDialogUi->fileTypeCombo->setEnabled(!testOption(ShowDirsOnly));
@@ -1859,6 +1879,7 @@ QFileDialog::AcceptMode QFileDialog::acceptMode() const
return static_cast<AcceptMode>(d->options->acceptMode());
}
+#if QT_DEPRECATED_SINCE(5, 13)
/*!
\property QFileDialog::readOnly
\obsolete
@@ -1918,6 +1939,7 @@ bool QFileDialog::confirmOverwrite() const
{
return !testOption(DontConfirmOverwrite);
}
+#endif
/*!
\property QFileDialog::defaultSuffix
@@ -2122,8 +2144,8 @@ QString QFileDialog::labelText(DialogLabel label) const
\snippet code/src_gui_dialogs_qfiledialog.cpp 8
The function creates a modal file dialog with the given \a parent widget.
- If \a parent is not 0, the dialog will be shown centered over the parent
- widget.
+ If \a parent is not \nullptr, the dialog will be shown centered over the
+ parent widget.
The file dialog's working directory will be set to \a dir. If \a dir
includes a file name, the file will be selected. Only files that match the
@@ -2145,8 +2167,8 @@ QString QFileDialog::labelText(DialogLabel label) const
native file dialog and not a QFileDialog.
On Windows the dialog will spin a blocking modal event loop that will not
- dispatch any QTimers, and if \a parent is not 0 then it will position the
- dialog just below the parent's title bar.
+ dispatch any QTimers, and if \a parent is not \nullptr then it will position
+ the dialog just below the parent's 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},
@@ -2235,8 +2257,8 @@ QUrl QFileDialog::getOpenFileUrl(QWidget *parent,
\snippet code/src_gui_dialogs_qfiledialog.cpp 9
This function creates a modal file dialog with the given \a parent widget.
- If \a parent is not 0, the dialog will be shown centered over the parent
- widget.
+ If \a parent is not \nullptr, the dialog will be shown centered over the
+ parent widget.
The file dialog's working directory will be set to \a dir. If \a dir
includes a file name, the file will be selected. The filter is set to
@@ -2254,8 +2276,8 @@ QUrl QFileDialog::getOpenFileUrl(QWidget *parent,
native file dialog and not a QFileDialog.
On Windows the dialog will spin a blocking modal event loop that will not
- dispatch any QTimers, and if \a parent is not 0 then it will position the
- dialog just below the parent's title bar.
+ dispatch any QTimers, and if \a parent is not \nullptr then it will position
+ the dialog just below the parent's 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},
@@ -2344,12 +2366,91 @@ QList<QUrl> QFileDialog::getOpenFileUrls(QWidget *parent,
}
/*!
+ This is a convenience static function that will return the content of a file
+ selected by the user.
+
+ This function is used to access local files on Qt for WebAssembly, where the web
+ sandbox places restrictions on how such access may happen. Its implementation will
+ make the browser display a native file dialog, where the user makes the file selection.
+
+ It can also be used on other platforms, where it will fall back to using QFileDialog.
+
+ The function is asynchronous and returns immediately. The \a fileOpenCompleted
+ callback will be called when a file has been selected and its contents has been
+ read into memory.
+
+ \snippet code/src_gui_dialogs_qfiledialog.cpp 14
+ \since 5.13
+*/
+void QFileDialog::getOpenFileContent(const QString &nameFilter, const std::function<void(const QString &, const QByteArray &)> &fileOpenCompleted)
+{
+#ifdef Q_OS_WASM
+ auto openFileImpl = std::make_shared<std::function<void(void)>>();
+ QString fileName;
+ QByteArray fileContent;
+ *openFileImpl = [=]() mutable {
+ auto fileDialogClosed = [&](bool fileSelected) {
+ if (!fileSelected) {
+ fileOpenCompleted(fileName, fileContent);
+ openFileImpl.reset();
+ }
+ };
+ auto acceptFile = [&](uint64_t size, const std::string name) -> char * {
+ const uint64_t twoGB = 1ULL << 31; // QByteArray limit
+ if (size > twoGB)
+ return nullptr;
+
+ fileName = QString::fromStdString(name);
+ fileContent.resize(size);
+ return fileContent.data();
+ };
+ auto fileContentReady = [&]() mutable {
+ fileOpenCompleted(fileName, fileContent);
+ openFileImpl.reset();
+ };
+
+ auto qtFilterStringToWebAcceptString = [](const QString &qtString) {
+ // The Qt and Web name filter string formats are similar, but
+ // not identical.
+ return qtString.toStdString(); // ### TODO
+ };
+
+ QWasmLocalFileAccess::openFile(qtFilterStringToWebAcceptString(nameFilter), fileDialogClosed, acceptFile, fileContentReady);
+ };
+
+ (*openFileImpl)();
+#else
+ QFileDialog *dialog = new QFileDialog();
+ dialog->selectNameFilter(nameFilter);
+
+ auto fileSelected = [=](const QString &fileName) {
+ QByteArray fileContent;
+ if (!fileName.isNull()) {
+ QFile selectedFile(fileName);
+ selectedFile.open(QIODevice::ReadOnly);
+ fileContent = selectedFile.readAll();
+ }
+ fileOpenCompleted(fileName, fileContent);
+ };
+
+ auto dialogClosed = [=](int code) {
+ Q_UNUSED(code);
+ delete dialog;
+ };
+
+ connect(dialog, &QFileDialog::fileSelected, fileSelected);
+ connect(dialog, &QFileDialog::finished, dialogClosed);
+ dialog->show();
+#endif
+}
+
+/*!
This is a convenience static function that will return a file name selected
by the user. The file does not have to exist.
It creates a modal file dialog with the given \a parent widget. If
- \a parent is not 0, the dialog will be shown centered over the parent
- widget.
+ \a parent is not \nullptr, the dialog will be shown centered over the
+ parent widget.
\snippet code/src_gui_dialogs_qfiledialog.cpp 11
@@ -2375,9 +2476,9 @@ QList<QUrl> QFileDialog::getOpenFileUrls(QWidget *parent,
native file dialog and not a QFileDialog.
On Windows the dialog will spin a blocking modal event loop that will not
- dispatch any QTimers, and if \a parent is not 0 then it will position the
- dialog just below the parent's title bar. On \macos, with its native file
- dialog, the filter argument is ignored.
+ dispatch any QTimers, and if \a parent is not \nullptr then it will
+ position the dialog just below the parent's title bar. On \macos, with its
+ native file dialog, the filter argument is ignored.
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},
@@ -2467,8 +2568,8 @@ QUrl QFileDialog::getSaveFileUrl(QWidget *parent,
\snippet code/src_gui_dialogs_qfiledialog.cpp 12
This function creates a modal file dialog with the given \a parent widget.
- If \a parent is not 0, the dialog will be shown centered over the parent
- widget.
+ If \a parent is not \nullptr, the dialog will be shown centered over the
+ parent widget.
The dialog's working directory is set to \a dir, and the caption is set to
\a caption. Either of these may be an empty string in which case the
@@ -2492,8 +2593,8 @@ QUrl QFileDialog::getSaveFileUrl(QWidget *parent,
symlinks as regular directories.
On Windows, the dialog will spin a blocking modal event loop that will not
- dispatch any QTimers, and if \a parent is not 0 then it will position the
- dialog just below the parent's title bar.
+ dispatch any QTimers, and if \a parent is not \nullptr then it will position
+ the dialog just below the parent's title bar.
\warning Do not delete \a parent during the execution of the dialog. If you
want to do this, you should create the dialog yourself using one of the
@@ -2548,7 +2649,10 @@ QUrl QFileDialog::getExistingDirectoryUrl(QWidget *parent,
args.parent = parent;
args.caption = caption;
args.directory = QFileDialogPrivate::workingDirectory(dir);
+QT_WARNING_PUSH
+QT_WARNING_DISABLE_DEPRECATED
args.mode = (options & ShowDirsOnly ? DirectoryOnly : Directory);
+QT_WARNING_POP
args.options = options;
QFileDialog dialog(args);
@@ -2661,7 +2765,10 @@ void QFileDialog::accept()
}
switch (fileMode()) {
+QT_WARNING_PUSH
+QT_WARNING_DISABLE_DEPRECATED
case DirectoryOnly:
+QT_WARNING_POP
case Directory: {
QString fn = files.first();
QFileInfo info(fn);
@@ -2697,7 +2804,7 @@ void QFileDialog::accept()
}
// check if we have to ask for permission to overwrite the file
- if (!info.exists() || !confirmOverwrite() || acceptMode() == AcceptOpen) {
+ if (!info.exists() || testOption(DontConfirmOverwrite) || acceptMode() == AcceptOpen) {
d->emitFilesSelected(QStringList(fn));
QDialog::accept();
#if QT_CONFIG(messagebox)
@@ -3565,7 +3672,10 @@ void QFileDialogPrivate::_q_updateOkButton()
isOpenDirectory = true;
} else {
switch (fileMode) {
+QT_WARNING_PUSH
+QT_WARNING_DISABLE_DEPRECATED
case QFileDialog::DirectoryOnly:
+QT_WARNING_POP
case QFileDialog::Directory: {
QString fn = files.first();
QModelIndex idx = model->index(fn);
@@ -3657,12 +3767,15 @@ void QFileDialogPrivate::_q_enterDirectory(const QModelIndex &index)
const QFileDialog::FileMode fileMode = q->fileMode();
q->setDirectory(path);
emit q->directoryEntered(path);
+QT_WARNING_PUSH
+QT_WARNING_DISABLE_DEPRECATED
if (fileMode == QFileDialog::Directory
|| fileMode == QFileDialog::DirectoryOnly) {
// ### find out why you have to do both of these.
lineEdit()->setText(QString());
lineEdit()->clear();
}
+QT_WARNING_POP
} else {
// Do not accept when shift-clicking to multi-select a file in environments with single-click-activation (KDE)
if (!q->style()->styleHint(QStyle::SH_ItemView_ActivateItemOnSingleClick, nullptr, qFileDialogUi->treeView)
@@ -3695,7 +3808,7 @@ void QFileDialogPrivate::_q_goToDirectory(const QString &path)
}
QDir dir(path2);
if (!dir.exists())
- dir = getEnvironmentVariable(path2);
+ dir.setPath(getEnvironmentVariable(path2));
if (dir.exists() || path2.isEmpty() || path2 == model->myComputer().toString()) {
_q_enterDirectory(index);
@@ -3754,7 +3867,10 @@ void QFileDialogPrivate::_q_selectionChanged()
{
const QFileDialog::FileMode fileMode = q_func()->fileMode();
const QModelIndexList indexes = qFileDialogUi->listView->selectionModel()->selectedRows();
+QT_WARNING_PUSH
+QT_WARNING_DISABLE_DEPRECATED
bool stripDirs = (fileMode != QFileDialog::DirectoryOnly && fileMode != QFileDialog::Directory);
+QT_WARNING_POP
QStringList allFiles;
for (const auto &index : indexes) {
@@ -3806,10 +3922,13 @@ void QFileDialogPrivate::_q_rowsInserted(const QModelIndex &parent)
void QFileDialogPrivate::_q_fileRenamed(const QString &path, const QString &oldName, const QString &newName)
{
const QFileDialog::FileMode fileMode = q_func()->fileMode();
+QT_WARNING_PUSH
+QT_WARNING_DISABLE_DEPRECATED
if (fileMode == QFileDialog::Directory || fileMode == QFileDialog::DirectoryOnly) {
if (path == rootPath() && lineEdit()->text() == oldName)
lineEdit()->setText(newName);
}
+QT_WARNING_POP
}
void QFileDialogPrivate::_q_emitUrlSelected(const QUrl &file)
diff --git a/src/widgets/dialogs/qfiledialog.h b/src/widgets/dialogs/qfiledialog.h
index a4d289a77a..95e03618ac 100644
--- a/src/widgets/dialogs/qfiledialog.h
+++ b/src/widgets/dialogs/qfiledialog.h
@@ -46,6 +46,8 @@
#include <QtCore/qurl.h>
#include <QtWidgets/qdialog.h>
+#include <functional>
+
QT_REQUIRE_CONFIG(filedialog);
QT_BEGIN_NAMESPACE
@@ -64,19 +66,22 @@ class Q_WIDGETS_EXPORT QFileDialog : public QDialog
Q_PROPERTY(ViewMode viewMode READ viewMode WRITE setViewMode)
Q_PROPERTY(FileMode fileMode READ fileMode WRITE setFileMode)
Q_PROPERTY(AcceptMode acceptMode READ acceptMode WRITE setAcceptMode)
+ Q_PROPERTY(QString defaultSuffix READ defaultSuffix WRITE setDefaultSuffix)
+#if QT_DEPRECATED_SINCE(5, 13)
Q_PROPERTY(bool readOnly READ isReadOnly WRITE setReadOnly DESIGNABLE false)
- Q_PROPERTY(bool resolveSymlinks READ resolveSymlinks WRITE setResolveSymlinks DESIGNABLE false)
Q_PROPERTY(bool confirmOverwrite READ confirmOverwrite WRITE setConfirmOverwrite DESIGNABLE false)
- Q_PROPERTY(QString defaultSuffix READ defaultSuffix WRITE setDefaultSuffix)
+ Q_PROPERTY(bool resolveSymlinks READ resolveSymlinks WRITE setResolveSymlinks DESIGNABLE false)
Q_PROPERTY(bool nameFilterDetailsVisible READ isNameFilterDetailsVisible
WRITE setNameFilterDetailsVisible DESIGNABLE false)
+#endif
Q_PROPERTY(Options options READ options WRITE setOptions)
Q_PROPERTY(QStringList supportedSchemes READ supportedSchemes WRITE setSupportedSchemes)
public:
enum ViewMode { Detail, List };
Q_ENUM(ViewMode)
- enum FileMode { AnyFile, ExistingFile, Directory, ExistingFiles, DirectoryOnly };
+ enum FileMode { AnyFile, ExistingFile, Directory, ExistingFiles,
+ DirectoryOnly Q_DECL_ENUMERATOR_DEPRECATED_X("Use setOption(ShowDirsOnly, true) instead")};
Q_ENUM(FileMode)
enum AcceptMode { AcceptOpen, AcceptSave };
Q_ENUM(AcceptMode)
@@ -117,8 +122,12 @@ public:
void selectUrl(const QUrl &url);
QList<QUrl> selectedUrls() const;
+#if QT_DEPRECATED_SINCE(5, 13)
+ QT_DEPRECATED_X("Use setOption(HideNameFilterDetails, !enabled) instead")
void setNameFilterDetailsVisible(bool enabled);
+ QT_DEPRECATED_X("Use !testOption(HideNameFilterDetails) instead")
bool isNameFilterDetailsVisible() const;
+#endif
void setNameFilter(const QString &filter);
void setNameFilters(const QStringList &filters);
@@ -145,11 +154,15 @@ public:
void setAcceptMode(AcceptMode mode);
AcceptMode acceptMode() const;
+#if QT_DEPRECATED_SINCE(5, 13)
void setReadOnly(bool enabled);
bool isReadOnly() const;
+ QT_DEPRECATED_X("Use setOption(DontResolveSymlinks, !enabled) instead")
void setResolveSymlinks(bool enabled);
+ QT_DEPRECATED_X("Use !testOption(DontResolveSymlinks) instead")
bool resolveSymlinks() const;
+#endif
void setSidebarUrls(const QList<QUrl> &urls);
QList<QUrl> sidebarUrls() const;
@@ -157,8 +170,12 @@ public:
QByteArray saveState() const;
bool restoreState(const QByteArray &state);
+#if QT_DEPRECATED_SINCE(5, 13)
+ QT_DEPRECATED_X("Use setOption(DontConfirmOverwrite, !enabled) instead")
void setConfirmOverwrite(bool enabled);
+ QT_DEPRECATED_X("Use !testOption(DontConfirmOverwrite) instead")
bool confirmOverwrite() const;
+#endif
void setDefaultSuffix(const QString &suffix);
QString defaultSuffix() const;
@@ -263,6 +280,8 @@ public:
Options options = Options(),
const QStringList &supportedSchemes = QStringList());
+ static void getOpenFileContent(const QString &nameFilter,
+ const std::function<void(const QString &, const QByteArray &)> &fileContentsReady);
protected:
QFileDialog(const QFileDialogArgs &args);
diff --git a/src/widgets/dialogs/qfiledialog_p.h b/src/widgets/dialogs/qfiledialog_p.h
index 2e49696b77..463c77aa23 100644
--- a/src/widgets/dialogs/qfiledialog_p.h
+++ b/src/widgets/dialogs/qfiledialog_p.h
@@ -164,13 +164,9 @@ public:
QDir::Filters filterForMode(QDir::Filters filters) const
{
- const QFileDialog::FileMode fileMode = q_func()->fileMode();
- if (fileMode == QFileDialog::DirectoryOnly) {
- filters |= QDir::Drives | QDir::AllDirs | QDir::Dirs;
+ filters |= QDir::Drives | QDir::AllDirs | QDir::Dirs | QDir::Files;
+ if (q_func()->testOption(QFileDialog::ShowDirsOnly))
filters &= ~QDir::Files;
- } else {
- filters |= QDir::Drives | QDir::AllDirs | QDir::Files | QDir::Dirs;
- }
return filters;
}
@@ -290,7 +286,7 @@ private:
virtual void helperPrepareShow(QPlatformDialogHelper *) override;
virtual void helperDone(QDialog::DialogCode, QPlatformDialogHelper *) override;
- Q_DISABLE_COPY(QFileDialogPrivate)
+ Q_DISABLE_COPY_MOVE(QFileDialogPrivate)
};
class QFileDialogLineEdit : public QLineEdit
diff --git a/src/widgets/dialogs/qfontdialog.cpp b/src/widgets/dialogs/qfontdialog.cpp
index 477c6bd540..2b81180ecb 100644
--- a/src/widgets/dialogs/qfontdialog.cpp
+++ b/src/widgets/dialogs/qfontdialog.cpp
@@ -534,7 +534,7 @@ void QFontDialogPrivate::updateFamilies()
//and try some fall backs
match_t type = MATCH_NONE;
- if (bestFamilyType <= MATCH_NONE && familyName2 == f.lastResortFamily())
+ if (bestFamilyType <= MATCH_NONE && familyName2 == QStringLiteral("helvetica"))
type = MATCH_LAST_RESORT;
if (bestFamilyType <= MATCH_LAST_RESORT && familyName2 == f.family())
type = MATCH_APP;
diff --git a/src/widgets/dialogs/qmessagebox.cpp b/src/widgets/dialogs/qmessagebox.cpp
index ac1952a642..f143e3b527 100644
--- a/src/widgets/dialogs/qmessagebox.cpp
+++ b/src/widgets/dialogs/qmessagebox.cpp
@@ -113,7 +113,7 @@ public:
, copyAvailable(false)
{
QVBoxLayout *layout = new QVBoxLayout;
- layout->setMargin(0);
+ layout->setContentsMargins(QMargins());
QFrame *line = new QFrame(this);
line->setFrameShape(QFrame::HLine);
line->setFrameShadow(QFrame::Sunken);
@@ -834,7 +834,7 @@ QMessageBox::QMessageBox(QWidget *parent)
The message box is an \l{Qt::ApplicationModal} {application modal}
dialog box.
- On \macos, if \a parent is not 0 and you want your message box
+ On \macos, if \a parent is not \nullptr and you want your message box
to appear as a Qt::Sheet of that parent, set the message box's
\l{setWindowModality()} {window modality} to Qt::WindowModal
(default). Otherwise, the message box will be a standard dialog.
@@ -983,7 +983,7 @@ QMessageBox::StandardButton QMessageBox::standardButton(QAbstractButton *button)
\since 4.2
Returns a pointer corresponding to the standard button \a which,
- or 0 if the standard button doesn't exist in this message box.
+ or \nullptr if the standard button doesn't exist in this message box.
\sa standardButtons, standardButton()
*/
@@ -1106,7 +1106,7 @@ void QMessageBoxPrivate::detectEscapeButton()
\since 4.2
Returns the button that was clicked by the user,
- or 0 if the user hit the \uicontrol Esc key and
+ or \nullptr if the user hit the \uicontrol Esc key and
no \l{setEscapeButton()}{escape button} was set.
If exec() hasn't been called yet, returns nullptr.
@@ -1173,7 +1173,7 @@ void QMessageBox::setDefaultButton(QMessageBox::StandardButton button)
/*! \since 5.2
Sets the checkbox \a cb on the message dialog. The message box takes ownership of the checkbox.
- The argument \a cb can be 0 to remove an existing checkbox from the message box.
+ The argument \a cb can be \nullptr to remove an existing checkbox from the message box.
\sa checkBox()
*/
@@ -1205,7 +1205,7 @@ void QMessageBox::setCheckBox(QCheckBox *cb)
/*! \since 5.2
- Returns the checkbox shown on the dialog. This is 0 if no checkbox is set.
+ Returns the checkbox shown on the dialog. This is \nullptr if no checkbox is set.
\sa setCheckBox()
*/
@@ -1570,7 +1570,7 @@ QList<QAbstractButton *> QMessageBox::buttons() const
\since 4.5
Returns the button role for the specified \a button. This function returns
- \l InvalidRole if \a button is 0 or has not been added to the message box.
+ \l InvalidRole if \a button is \nullptr or has not been added to the message box.
\sa buttons(), addButton()
*/
@@ -1835,7 +1835,7 @@ void QMessageBox::about(QWidget *parent, const QString &title, const QString &te
/*!
Displays a simple message box about Qt, with the given \a title
- and centered over \a parent (if \a parent is not 0). The message
+ and centered over \a parent (if \a parent is not \nullptr). The message
includes the version number of Qt being used by the application.
This is useful for inclusion in the \uicontrol Help menu of an application,
diff --git a/src/widgets/dialogs/qmessagebox.h b/src/widgets/dialogs/qmessagebox.h
index 4b993a9e65..0a2edb1eee 100644
--- a/src/widgets/dialogs/qmessagebox.h
+++ b/src/widgets/dialogs/qmessagebox.h
@@ -284,9 +284,9 @@ public:
Q_SIGNALS:
void buttonClicked(QAbstractButton *button);
-#ifdef Q_QDOC
+#ifdef Q_CLANG_QDOC
public Q_SLOTS:
- int exec();
+ int exec() override;
#endif
protected:
diff --git a/src/widgets/dialogs/qprogressdialog.cpp b/src/widgets/dialogs/qprogressdialog.cpp
index e1fb1055ae..078dd6463b 100644
--- a/src/widgets/dialogs/qprogressdialog.cpp
+++ b/src/widgets/dialogs/qprogressdialog.cpp
@@ -47,7 +47,6 @@
#include "qapplication.h"
#include "qstyle.h"
#include "qpushbutton.h"
-#include "qcursor.h"
#include "qtimer.h"
#include "qelapsedtimer.h"
#include <private/qdialog_p.h>
@@ -94,9 +93,6 @@ public:
bool cancellation_flag;
bool setValue_called;
QElapsedTimer starttime;
-#ifndef QT_NO_CURSOR
- QCursor parentCursor;
-#endif
int showTime;
bool autoClose;
bool autoReset;
@@ -597,12 +593,6 @@ void QProgressDialog::setRange(int minimum, int maximum)
void QProgressDialog::reset()
{
Q_D(QProgressDialog);
-#ifndef QT_NO_CURSOR
- if (value() >= 0) {
- if (parentWidget())
- parentWidget()->setCursor(d->parentCursor);
- }
-#endif
if (d->autoClose || d->forceHide)
hide();
d->bar->reset();
diff --git a/src/widgets/dialogs/qsidebar.cpp b/src/widgets/dialogs/qsidebar.cpp
index d52f18b406..2c8c66e1e2 100644
--- a/src/widgets/dialogs/qsidebar.cpp
+++ b/src/widgets/dialogs/qsidebar.cpp
@@ -381,8 +381,6 @@ QSidebar::QSidebar(QWidget *parent) : QListView(parent)
void QSidebar::setModelAndUrls(QFileSystemModel *model, const QList<QUrl> &newUrls)
{
- // ### TODO make icon size dynamic
- setIconSize(QSize(24,24));
setUniformItemSizes(true);
urlModel = new QUrlModel(this);
urlModel->setFileSystemModel(model);
diff --git a/src/widgets/dialogs/qwizard.cpp b/src/widgets/dialogs/qwizard.cpp
index 21e1ff2778..88b187cd7f 100644
--- a/src/widgets/dialogs/qwizard.cpp
+++ b/src/widgets/dialogs/qwizard.cpp
@@ -331,7 +331,7 @@ QWizardHeader::QWizardHeader(QWidget *parent)
titleLabel->setFont(font);
layout = new QGridLayout(this);
- layout->setMargin(0);
+ layout->setContentsMargins(QMargins());
layout->setSpacing(0);
layout->setRowMinimumHeight(3, 1);
@@ -769,7 +769,7 @@ void QWizardPrivate::reset()
for (int i = history.count() - 1; i >= 0; --i)
q->cleanupPage(history.at(i));
history.clear();
- for (QWizardPage *page : pageMap)
+ for (QWizardPage *page : qAsConst(pageMap))
page->d_func()->initialized = false;
current = -1;
@@ -1032,13 +1032,13 @@ void QWizardPrivate::recreateLayout(const QWizardLayoutInfo &info)
int pageColumn = qMin(1, numColumns - 1);
if (mac) {
- mainLayout->setMargin(0);
+ mainLayout->setContentsMargins(QMargins());
mainLayout->setSpacing(0);
buttonLayout->setContentsMargins(MacLayoutLeftMargin, MacButtonTopMargin, MacLayoutRightMargin, MacLayoutBottomMargin);
- pageVBoxLayout->setMargin(7);
+ pageVBoxLayout->setContentsMargins(7, 7, 7, 7);
} else {
if (modern) {
- mainLayout->setMargin(0);
+ mainLayout->setContentsMargins(QMargins());
mainLayout->setSpacing(0);
pageVBoxLayout->setContentsMargins(deltaMarginLeft, deltaMarginTop,
deltaMarginRight, deltaMarginBottom);
@@ -2374,8 +2374,8 @@ void QWizard::removePage(int id)
/*!
\fn QWizardPage *QWizard::page(int id) const
- Returns the page with the given \a id, or 0 if there is no such
- page.
+ Returns the page with the given \a id, or \nullptr if there is no
+ such page.
\sa addPage(), setPage()
*/
@@ -2462,8 +2462,8 @@ int QWizard::startId() const
}
/*!
- Returns a pointer to the current page, or 0 if there is no current
- page (e.g., before the wizard is shown).
+ Returns a pointer to the current page, or \nullptr if there is no
+ current page (e.g., before the wizard is shown).
This is equivalent to calling page(currentId()).
@@ -2954,7 +2954,7 @@ void QWizard::setDefaultProperty(const char *className, const char *property,
Passing 0 shows no side widget.
- When the \a widget is not 0 the wizard reparents it.
+ When the \a widget is not \nullptr the wizard reparents it.
Any previous side widget is hidden.
@@ -2963,7 +2963,7 @@ void QWizard::setDefaultProperty(const char *className, const char *property,
All widgets set here will be deleted by the wizard when it is
destroyed unless you separately reparent the widget after setting
- some other side widget (or 0).
+ some other side widget (or \nullptr).
By default, no side widget is present.
*/
@@ -2981,7 +2981,7 @@ void QWizard::setSideWidget(QWidget *widget)
/*!
\since 4.7
- Returns the widget on the left side of the wizard or 0.
+ Returns the widget on the left side of the wizard or \nullptr.
By default, no side widget is present.
*/
@@ -3969,7 +3969,7 @@ void QWizardPage::registerField(const QString &name, QWidget *widget, const char
}
/*!
- Returns the wizard associated with this page, or 0 if this page
+ Returns the wizard associated with this page, or \nullptr if this page
hasn't been inserted into a QWizard yet.
\sa QWizard::addPage(), QWizard::setPage()
diff --git a/src/widgets/dialogs/qwizard_win_p.h b/src/widgets/dialogs/qwizard_win_p.h
index d302dedaa3..02c5e52c2c 100644
--- a/src/widgets/dialogs/qwizard_win_p.h
+++ b/src/widgets/dialogs/qwizard_win_p.h
@@ -84,7 +84,7 @@ class QWizard;
class QVistaHelper : public QObject
{
- Q_DISABLE_COPY(QVistaHelper)
+ Q_DISABLE_COPY_MOVE(QVistaHelper)
public:
QVistaHelper(QWizard *wizard);
~QVistaHelper() override;