diff options
Diffstat (limited to 'src/widgets/dialogs')
-rw-r--r-- | src/widgets/dialogs/qcolordialog.cpp | 6 | ||||
-rw-r--r-- | src/widgets/dialogs/qfiledialog.cpp | 31 | ||||
-rw-r--r-- | src/widgets/dialogs/qfiledialog.h | 3 | ||||
-rw-r--r-- | src/widgets/dialogs/qfiledialog_p.h | 16 | ||||
-rw-r--r-- | src/widgets/dialogs/qfileinfogatherer.cpp | 48 | ||||
-rw-r--r-- | src/widgets/dialogs/qfileinfogatherer_p.h | 4 | ||||
-rw-r--r-- | src/widgets/dialogs/qfontdialog.cpp | 3 | ||||
-rw-r--r-- | src/widgets/dialogs/qmessagebox.h | 2 | ||||
-rw-r--r-- | src/widgets/dialogs/qwizard.cpp | 2 | ||||
-rw-r--r-- | src/widgets/dialogs/qwizard.h | 4 | ||||
-rw-r--r-- | src/widgets/dialogs/qwizard_win.cpp | 3 |
11 files changed, 93 insertions, 29 deletions
diff --git a/src/widgets/dialogs/qcolordialog.cpp b/src/widgets/dialogs/qcolordialog.cpp index 39eacae596..ab3099dfe8 100644 --- a/src/widgets/dialogs/qcolordialog.cpp +++ b/src/widgets/dialogs/qcolordialog.cpp @@ -355,7 +355,7 @@ void QWellArray::paintCell(QPainter* p, int row, int col, const QRect &rect) paintCellContents(p, row, col, opt.rect.adjusted(dfw, dfw, -dfw, -dfw)); } -/*! +/* Reimplement this function to change the contents of the well array. */ void QWellArray::paintCellContents(QPainter *p, int row, int col, const QRect &r) @@ -441,16 +441,12 @@ void QWellArray::focusInEvent(QFocusEvent*) emit currentChanged(curRow, curCol); } -/*!\reimp -*/ void QWellArray::focusOutEvent(QFocusEvent*) { updateCell(curRow, curCol); } -/*\reimp -*/ void QWellArray::keyPressEvent(QKeyEvent* e) { switch(e->key()) { // Look at the key code diff --git a/src/widgets/dialogs/qfiledialog.cpp b/src/widgets/dialogs/qfiledialog.cpp index 74875faf21..5bfb7553a5 100644 --- a/src/widgets/dialogs/qfiledialog.cpp +++ b/src/widgets/dialogs/qfiledialog.cpp @@ -860,7 +860,7 @@ void QFileDialog::setVisible(bool visible) } } - if (d->usingWidgets()) + if (visible && d->usingWidgets()) d->qFileDialogUi->fileNameEdit->setFocus(); QDialog::setVisible(visible); @@ -1461,6 +1461,19 @@ void QFileDialog::selectNameFilter(const QString &filter) } /*! + * \since 5.9 + * \return The mimetype of the file that the user selected in the file dialog. + */ +QString QFileDialog::selectedMimeTypeFilter() const +{ + Q_D(const QFileDialog); + if (!d->usingWidgets()) + return d->selectedMimeTypeFilter_sys(); + + return d->options->initiallySelectedMimeTypeFilter(); +} + +/*! \since 4.4 Returns the filter that the user selected in the file dialog. @@ -1579,9 +1592,19 @@ QStringList QFileDialog::mimeTypeFilters() const */ void QFileDialog::selectMimeTypeFilter(const QString &filter) { - const QString text = nameFilterForMime(filter); - if (!text.isEmpty()) - selectNameFilter(text); + Q_D(QFileDialog); + d->options->setInitiallySelectedMimeTypeFilter(filter); + + const QString filterForMime = nameFilterForMime(filter); + + if (!d->usingWidgets()) { + d->selectMimeTypeFilter_sys(filter); + if (d->selectedMimeTypeFilter_sys().isEmpty() && !filterForMime.isEmpty()) { + selectNameFilter(filterForMime); + } + } else if (!filterForMime.isEmpty()) { + selectNameFilter(filterForMime); + } } #endif // QT_NO_MIMETYPE diff --git a/src/widgets/dialogs/qfiledialog.h b/src/widgets/dialogs/qfiledialog.h index 4ade50793d..7959eebd7b 100644 --- a/src/widgets/dialogs/qfiledialog.h +++ b/src/widgets/dialogs/qfiledialog.h @@ -62,7 +62,6 @@ class QAbstractProxyModel; class Q_WIDGETS_EXPORT QFileDialog : public QDialog { Q_OBJECT - Q_FLAGS(Options) Q_PROPERTY(ViewMode viewMode READ viewMode WRITE setViewMode) Q_PROPERTY(FileMode fileMode READ fileMode WRITE setFileMode) Q_PROPERTY(AcceptMode acceptMode READ acceptMode WRITE setAcceptMode) @@ -97,6 +96,7 @@ public: }; Q_ENUM(Option) Q_DECLARE_FLAGS(Options, Option) + Q_FLAG(Options) QFileDialog(QWidget *parent, Qt::WindowFlags f); explicit QFileDialog(QWidget *parent = Q_NULLPTR, @@ -125,6 +125,7 @@ public: void setNameFilters(const QStringList &filters); QStringList nameFilters() const; void selectNameFilter(const QString &filter); + QString selectedMimeTypeFilter() const; QString selectedNameFilter() const; #ifndef QT_NO_MIMETYPE diff --git a/src/widgets/dialogs/qfiledialog_p.h b/src/widgets/dialogs/qfiledialog_p.h index afebad4457..b665b54a9b 100644 --- a/src/widgets/dialogs/qfiledialog_p.h +++ b/src/widgets/dialogs/qfiledialog_p.h @@ -258,6 +258,8 @@ public: void selectFile_sys(const QUrl &filename); QList<QUrl> selectedFiles_sys() const; void setFilter_sys(); + void selectMimeTypeFilter_sys(const QString &filter); + QString selectedMimeTypeFilter_sys() const; void selectNameFilter_sys(const QString &filter); QString selectedNameFilter_sys() const; ////////////////////////////////////////////// @@ -400,6 +402,20 @@ inline void QFileDialogPrivate::setFilter_sys() helper->setFilter(); } +inline void QFileDialogPrivate::selectMimeTypeFilter_sys(const QString &filter) +{ + if (QPlatformFileDialogHelper *helper = platformFileDialogHelper()) + helper->selectMimeTypeFilter(filter); +} + +QString QFileDialogPrivate::selectedMimeTypeFilter_sys() const +{ + if (QPlatformFileDialogHelper *helper = platformFileDialogHelper()) + return helper->selectedMimeTypeFilter(); + + return QString(); +} + inline void QFileDialogPrivate::selectNameFilter_sys(const QString &filter) { if (QPlatformFileDialogHelper *helper = platformFileDialogHelper()) diff --git a/src/widgets/dialogs/qfileinfogatherer.cpp b/src/widgets/dialogs/qfileinfogatherer.cpp index 6df020dd58..08c5a40c7c 100644 --- a/src/widgets/dialogs/qfileinfogatherer.cpp +++ b/src/widgets/dialogs/qfileinfogatherer.cpp @@ -65,6 +65,18 @@ Q_AUTOTEST_EXPORT bool qt_test_isFetchedRoot() } #endif +static QString translateDriveName(const QFileInfo &drive) +{ + QString driveName = drive.absoluteFilePath(); +#ifdef Q_OS_WIN + if (driveName.startsWith(QLatin1Char('/'))) // UNC host + return drive.fileName(); + if (driveName.endsWith(QLatin1Char('/'))) + driveName.chop(1); +#endif // Q_OS_WIN + return driveName; +} + /*! Creates thread */ @@ -82,6 +94,16 @@ QFileInfoGatherer::QFileInfoGatherer(QObject *parent) watcher = new QFileSystemWatcher(this); connect(watcher, SIGNAL(directoryChanged(QString)), this, SLOT(list(QString))); connect(watcher, SIGNAL(fileChanged(QString)), this, SLOT(updateFile(QString))); + +# if defined(Q_OS_WIN) && !defined(Q_OS_WINRT) + const QVariant listener = watcher->property("_q_driveListener"); + if (listener.canConvert<QObject *>()) { + if (QObject *driveListener = listener.value<QObject *>()) { + connect(driveListener, SIGNAL(driveAdded()), this, SLOT(driveAdded())); + connect(driveListener, SIGNAL(driveRemoved(QString)), this, SLOT(driveRemoved())); + } + } +# endif // Q_OS_WIN && !Q_OS_WINRT #endif start(LowPriority); } @@ -106,6 +128,20 @@ void QFileInfoGatherer::setResolveSymlinks(bool enable) #endif } +void QFileInfoGatherer::driveAdded() +{ + fetchExtendedInformation(QString(), QStringList()); +} + +void QFileInfoGatherer::driveRemoved() +{ + QStringList drives; + const QFileInfoList driveInfoList = QDir::drives(); + for (const QFileInfo &fi : driveInfoList) + drives.append(translateDriveName(fi)); + newListOfFiles(QString(), drives); +} + bool QFileInfoGatherer::resolveSymlinks() const { #ifdef Q_OS_WIN @@ -260,18 +296,6 @@ QExtendedInformation QFileInfoGatherer::getInfo(const QFileInfo &fileInfo) const return info; } -static QString translateDriveName(const QFileInfo &drive) -{ - QString driveName = drive.absoluteFilePath(); -#if defined(Q_OS_WIN) - if (driveName.startsWith(QLatin1Char('/'))) // UNC host - return drive.fileName(); - if (driveName.endsWith(QLatin1Char('/'))) - driveName.chop(1); -#endif - return driveName; -} - /* Get specific file info's, batch the files so update when we have 100 items and every 200ms after that diff --git a/src/widgets/dialogs/qfileinfogatherer_p.h b/src/widgets/dialogs/qfileinfogatherer_p.h index 3186e9d015..0018b6c387 100644 --- a/src/widgets/dialogs/qfileinfogatherer_p.h +++ b/src/widgets/dialogs/qfileinfogatherer_p.h @@ -180,6 +180,10 @@ public Q_SLOTS: void setResolveSymlinks(bool enable); void setIconProvider(QFileIconProvider *provider); +private Q_SLOTS: + void driveAdded(); + void driveRemoved(); + private: void run() Q_DECL_OVERRIDE; // called by run(): diff --git a/src/widgets/dialogs/qfontdialog.cpp b/src/widgets/dialogs/qfontdialog.cpp index 955e93a26f..b20a1449eb 100644 --- a/src/widgets/dialogs/qfontdialog.cpp +++ b/src/widgets/dialogs/qfontdialog.cpp @@ -867,8 +867,7 @@ QFont QFontDialog::selectedFont() const \value NoButtons Don't display \uicontrol{OK} and \uicontrol{Cancel} buttons. (Useful for "live dialogs".) \value DontUseNativeDialog Use Qt's standard font dialog on the Mac instead of Apple's - native font panel. (Currently, the native dialog is never used, - but this is likely to change in future Qt releases.) + native font panel. \value ScalableFonts Show scalable fonts \value NonScalableFonts Show non scalable fonts \value MonospacedFonts Show monospaced fonts diff --git a/src/widgets/dialogs/qmessagebox.h b/src/widgets/dialogs/qmessagebox.h index c6a55964fe..3e561a5161 100644 --- a/src/widgets/dialogs/qmessagebox.h +++ b/src/widgets/dialogs/qmessagebox.h @@ -56,7 +56,6 @@ class QCheckBox; class Q_WIDGETS_EXPORT QMessageBox : public QDialog { Q_OBJECT - Q_FLAGS(StandardButtons) Q_PROPERTY(QString text READ text WRITE setText) Q_PROPERTY(Icon icon READ icon WRITE setIcon) Q_PROPERTY(QPixmap iconPixmap READ iconPixmap WRITE setIconPixmap) @@ -131,6 +130,7 @@ public: typedef StandardButton Button; // obsolete Q_DECLARE_FLAGS(StandardButtons, StandardButton) + Q_FLAG(StandardButtons) explicit QMessageBox(QWidget *parent = Q_NULLPTR); QMessageBox(Icon icon, const QString &title, const QString &text, diff --git a/src/widgets/dialogs/qwizard.cpp b/src/widgets/dialogs/qwizard.cpp index 9153d7ea41..532ee4700f 100644 --- a/src/widgets/dialogs/qwizard.cpp +++ b/src/widgets/dialogs/qwizard.cpp @@ -3255,7 +3255,7 @@ void QWizard::paintEvent(QPaintEvent * event) #endif } -#if defined(Q_OS_WIN) +#if defined(Q_OS_WIN) || defined(Q_CLANG_QDOC) /*! \reimp */ diff --git a/src/widgets/dialogs/qwizard.h b/src/widgets/dialogs/qwizard.h index 9ce68b6566..7915c9e7f8 100644 --- a/src/widgets/dialogs/qwizard.h +++ b/src/widgets/dialogs/qwizard.h @@ -55,7 +55,6 @@ class QWizardPrivate; class Q_WIDGETS_EXPORT QWizard : public QDialog { Q_OBJECT - Q_FLAGS(WizardOptions) Q_PROPERTY(WizardStyle wizardStyle READ wizardStyle WRITE setWizardStyle) Q_PROPERTY(WizardOptions options READ options WRITE setOptions) Q_PROPERTY(Qt::TextFormat titleFormat READ titleFormat WRITE setTitleFormat) @@ -120,6 +119,7 @@ public: Q_ENUM(WizardOption) Q_DECLARE_FLAGS(WizardOptions, WizardOption) + Q_FLAG(WizardOptions) explicit QWizard(QWidget *parent = Q_NULLPTR, Qt::WindowFlags flags = Qt::WindowFlags()); ~QWizard(); @@ -188,7 +188,7 @@ protected: bool event(QEvent *event) Q_DECL_OVERRIDE; void resizeEvent(QResizeEvent *event) Q_DECL_OVERRIDE; void paintEvent(QPaintEvent *event) Q_DECL_OVERRIDE; -#ifdef Q_OS_WIN +#if defined(Q_OS_WIN) || defined(Q_CLANG_QDOC) bool nativeEvent(const QByteArray &eventType, void *message, long *result) Q_DECL_OVERRIDE; #endif void done(int result) Q_DECL_OVERRIDE; diff --git a/src/widgets/dialogs/qwizard_win.cpp b/src/widgets/dialogs/qwizard_win.cpp index 80e37dab25..4f6ef49a7f 100644 --- a/src/widgets/dialogs/qwizard_win.cpp +++ b/src/widgets/dialogs/qwizard_win.cpp @@ -49,6 +49,7 @@ #include "qwizard.h" #include "qpaintengine.h" #include "qapplication.h" +#include <QtCore/QOperatingSystemVersion> #include <QtCore/QVariant> #include <QtCore/QDebug> #include <QtGui/QMouseEvent> @@ -718,7 +719,7 @@ int QVistaHelper::topOffset() if (vistaState() != VistaAero) return titleBarSize() + 3; static const int aeroOffset = - QSysInfo::WindowsVersion == QSysInfo::WV_WINDOWS7 ? + QOperatingSystemVersion::current() < QOperatingSystemVersion::Windows8 ? QStyleHelper::dpiScaled(4) : QStyleHelper::dpiScaled(13); return aeroOffset + titleBarSize(); } |