summaryrefslogtreecommitdiffstats
path: root/src/widgets/dialogs
diff options
context:
space:
mode:
Diffstat (limited to 'src/widgets/dialogs')
-rw-r--r--src/widgets/dialogs/qfiledialog.cpp49
-rw-r--r--src/widgets/dialogs/qfiledialog.h1
-rw-r--r--src/widgets/dialogs/qfileinfogatherer.cpp117
-rw-r--r--src/widgets/dialogs/qfileinfogatherer_p.h20
-rw-r--r--src/widgets/dialogs/qfilesystemmodel.cpp103
-rw-r--r--src/widgets/dialogs/qfilesystemmodel.h17
-rw-r--r--src/widgets/dialogs/qwizard.cpp12
-rw-r--r--src/widgets/dialogs/qwizard_win.cpp36
-rw-r--r--src/widgets/dialogs/qwizard_win_p.h16
9 files changed, 308 insertions, 63 deletions
diff --git a/src/widgets/dialogs/qfiledialog.cpp b/src/widgets/dialogs/qfiledialog.cpp
index c85b56d4f5..a1b9003c1c 100644
--- a/src/widgets/dialogs/qfiledialog.cpp
+++ b/src/widgets/dialogs/qfiledialog.cpp
@@ -2379,10 +2379,10 @@ QList<QUrl> QFileDialog::getOpenFileUrls(QWidget *parent,
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
+ callback will be called when a file has been selected and its contents have been
read into memory.
- \snippet code/src_gui_dialogs_qfiledialog.cpp 14
+ \snippet code/src_gui_dialogs_qfiledialog.cpp 15
\since 5.13
*/
void QFileDialog::getOpenFileContent(const QString &nameFilter, const std::function<void(const QString &, const QByteArray &)> &fileOpenCompleted)
@@ -2448,6 +2448,51 @@ void QFileDialog::getOpenFileContent(const QString &nameFilter, const std::funct
}
/*!
+ This is a convenience static function that saves \a fileContent to a file, using
+ a file name and location chosen by the user. \a fileNameHint can be provided to
+ suggest a file name to the user.
+
+ This function is used to save files to the local file system 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.
+
+ \snippet code/src_gui_dialogs_qfiledialog.cpp 16
+ \since 5.14
+*/
+void QFileDialog::saveFileContent(const QByteArray &fileContent, const QString &fileNameHint)
+{
+#ifdef Q_OS_WASM
+ QWasmLocalFileAccess::saveFile(fileContent.constData(), fileContent.size(), fileNameHint.toStdString());
+#else
+ QFileDialog *dialog = new QFileDialog();
+ dialog->setAcceptMode(QFileDialog::AcceptSave);
+ dialog->setFileMode(QFileDialog::AnyFile);
+ dialog->selectFile(fileNameHint);
+
+ auto fileSelected = [=](const QString &fileName) {
+ if (!fileName.isNull()) {
+ QFile selectedFile(fileName);
+ if (selectedFile.open(QIODevice::WriteOnly))
+ selectedFile.write(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.
diff --git a/src/widgets/dialogs/qfiledialog.h b/src/widgets/dialogs/qfiledialog.h
index 354a1f928b..790f52f2e7 100644
--- a/src/widgets/dialogs/qfiledialog.h
+++ b/src/widgets/dialogs/qfiledialog.h
@@ -284,6 +284,7 @@ public:
static void getOpenFileContent(const QString &nameFilter,
const std::function<void(const QString &, const QByteArray &)> &fileContentsReady);
+ static void saveFileContent(const QByteArray &fileContent, const QString &fileNameHint = QString());
protected:
QFileDialog(const QFileDialogArgs &args);
diff --git a/src/widgets/dialogs/qfileinfogatherer.cpp b/src/widgets/dialogs/qfileinfogatherer.cpp
index 9ab75e0b0a..0beca82f28 100644
--- a/src/widgets/dialogs/qfileinfogatherer.cpp
+++ b/src/widgets/dialogs/qfileinfogatherer.cpp
@@ -82,21 +82,6 @@ QFileInfoGatherer::QFileInfoGatherer(QObject *parent)
: QThread(parent)
, m_iconProvider(&defaultProvider)
{
-#if QT_CONFIG(filesystemwatcher)
- 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()), this, SLOT(driveRemoved()));
- }
- }
-# endif // Q_OS_WIN && !Q_OS_WINRT
-#endif
start(LowPriority);
}
@@ -177,8 +162,8 @@ void QFileInfoGatherer::fetchExtendedInformation(const QString &path, const QStr
if (files.isEmpty()
&& !path.isEmpty()
&& !path.startsWith(QLatin1String("//")) /*don't watch UNC path*/) {
- if (!watcher->directories().contains(path))
- watcher->addPath(path);
+ if (!watchedDirectories().contains(path))
+ watchPaths(QStringList(path));
}
#endif
}
@@ -195,6 +180,91 @@ void QFileInfoGatherer::updateFile(const QString &filePath)
fetchExtendedInformation(dir, QStringList(fileName));
}
+QStringList QFileInfoGatherer::watchedFiles() const
+{
+#if QT_CONFIG(filesystemwatcher)
+ if (m_watcher)
+ return m_watcher->files();
+#endif
+ return {};
+}
+
+QStringList QFileInfoGatherer::watchedDirectories() const
+{
+#if QT_CONFIG(filesystemwatcher)
+ if (m_watcher)
+ return m_watcher->directories();
+#endif
+ return {};
+}
+
+void QFileInfoGatherer::createWatcher()
+{
+#if QT_CONFIG(filesystemwatcher)
+ m_watcher = new QFileSystemWatcher(this);
+ connect(m_watcher, &QFileSystemWatcher::directoryChanged, this, &QFileInfoGatherer::list);
+ connect(m_watcher, &QFileSystemWatcher::fileChanged, this, &QFileInfoGatherer::updateFile);
+# if defined(Q_OS_WIN) && !defined(Q_OS_WINRT)
+ const QVariant listener = m_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()), this, SLOT(driveRemoved()));
+ }
+ }
+# endif // Q_OS_WIN && !Q_OS_WINRT
+#endif
+}
+
+void QFileInfoGatherer::watchPaths(const QStringList &paths)
+{
+#if QT_CONFIG(filesystemwatcher)
+ if (m_watching) {
+ if (m_watcher == nullptr)
+ createWatcher();
+ m_watcher->addPaths(paths);
+ }
+#else
+ Q_UNUSED(paths);
+#endif
+}
+
+void QFileInfoGatherer::unwatchPaths(const QStringList &paths)
+{
+#if QT_CONFIG(filesystemwatcher)
+ if (m_watcher)
+ m_watcher->removePaths(paths);
+#else
+ Q_UNUSED(paths);
+#endif
+}
+
+bool QFileInfoGatherer::isWatching() const
+{
+ bool result = false;
+#if QT_CONFIG(filesystemwatcher)
+ QMutexLocker locker(&mutex);
+ result = m_watching;
+#endif
+ return result;
+}
+
+void QFileInfoGatherer::setWatching(bool v)
+{
+#if QT_CONFIG(filesystemwatcher)
+ QMutexLocker locker(&mutex);
+ if (v != m_watching) {
+ if (!v) {
+ delete m_watcher;
+ m_watcher = nullptr;
+ }
+ m_watching = v;
+ }
+#else
+ Q_UNUSED(v);
+#endif
+}
+
/*
List all files in \a directoryPath
@@ -204,8 +274,8 @@ void QFileInfoGatherer::clear()
{
#if QT_CONFIG(filesystemwatcher)
QMutexLocker locker(&mutex);
- watcher->removePaths(watcher->files());
- watcher->removePaths(watcher->directories());
+ unwatchPaths(watchedFiles());
+ unwatchPaths(watchedDirectories());
#endif
}
@@ -218,7 +288,7 @@ void QFileInfoGatherer::removePath(const QString &path)
{
#if QT_CONFIG(filesystemwatcher)
QMutexLocker locker(&mutex);
- watcher->removePath(path);
+ unwatchPaths(QStringList(path));
#else
Q_UNUSED(path);
#endif
@@ -265,12 +335,13 @@ QExtendedInformation QFileInfoGatherer::getInfo(const QFileInfo &fileInfo) const
static const bool watchFiles = qEnvironmentVariableIsSet("QT_FILESYSTEMMODEL_WATCH_FILES");
if (watchFiles) {
if (!fileInfo.exists() && !fileInfo.isSymLink()) {
- watcher->removePath(fileInfo.absoluteFilePath());
+ const_cast<QFileInfoGatherer *>(this)->
+ unwatchPaths(QStringList(fileInfo.absoluteFilePath()));
} else {
const QString path = fileInfo.absoluteFilePath();
if (!path.isEmpty() && fileInfo.exists() && fileInfo.isFile() && fileInfo.isReadable()
- && !watcher->files().contains(path)) {
- watcher->addPath(path);
+ && !watchedFiles().contains(path)) {
+ const_cast<QFileInfoGatherer *>(this)->watchPaths(QStringList(path));
}
}
}
diff --git a/src/widgets/dialogs/qfileinfogatherer_p.h b/src/widgets/dialogs/qfileinfogatherer_p.h
index 829c620c1e..3d30a98d04 100644
--- a/src/widgets/dialogs/qfileinfogatherer_p.h
+++ b/src/widgets/dialogs/qfileinfogatherer_p.h
@@ -169,12 +169,13 @@ public:
explicit QFileInfoGatherer(QObject *parent = nullptr);
~QFileInfoGatherer();
-#if QT_CONFIG(filesystemwatcher) && defined(Q_OS_WIN)
- QStringList watchedFiles() const { return watcher->files(); }
- QStringList watchedDirectories() const { return watcher->directories(); }
- void watchPaths(const QStringList &paths) { watcher->addPaths(paths); }
- void unwatchPaths(const QStringList &paths) { watcher->removePaths(paths); }
-#endif // filesystemwatcher && Q_OS_WIN
+ QStringList watchedFiles() const;
+ QStringList watchedDirectories() const;
+ void watchPaths(const QStringList &paths);
+ void unwatchPaths(const QStringList &paths);
+
+ bool isWatching() const;
+ void setWatching(bool v);
// only callable from this->thread():
void clear();
@@ -201,6 +202,8 @@ private:
void fetch(const QFileInfo &info, QElapsedTimer &base, bool &firstTime, QVector<QPair<QString, QFileInfo> > &updatedFiles, const QString &path);
private:
+ void createWatcher();
+
mutable QMutex mutex;
// begin protected by mutex
QWaitCondition condition;
@@ -210,13 +213,16 @@ private:
QAtomicInt abort;
#if QT_CONFIG(filesystemwatcher)
- QFileSystemWatcher *watcher = nullptr;
+ QFileSystemWatcher *m_watcher = nullptr;
#endif
QFileIconProvider *m_iconProvider; // not accessed by run()
QFileIconProvider defaultProvider;
#ifdef Q_OS_WIN
bool m_resolveSymlinks = true; // not accessed by run()
#endif
+#if QT_CONFIG(filesystemwatcher)
+ bool m_watching = true;
+#endif
};
QT_END_NAMESPACE
diff --git a/src/widgets/dialogs/qfilesystemmodel.cpp b/src/widgets/dialogs/qfilesystemmodel.cpp
index 820fc6e220..e9e49e0c33 100644
--- a/src/widgets/dialogs/qfilesystemmodel.cpp
+++ b/src/widgets/dialogs/qfilesystemmodel.cpp
@@ -1264,6 +1264,107 @@ Qt::DropActions QFileSystemModel::supportedDropActions() const
}
/*!
+ \enum QFileSystemModel::Option
+ \since 5.14
+
+ \value DontWatchForChanges Do not add file watchers to the paths.
+ This reduces overhead when using the model for simple tasks
+ like line edit completion.
+
+ \value DontResolveSymlinks Don't resolve symlinks in the file
+ system model. By default, symlinks are resolved.
+
+ \value DontUseCustomDirectoryIcons Always use the default directory icon.
+ Some platforms allow the user to set a different icon. Custom icon lookup
+ causes a big performance impact over network or removable drives.
+ This sets the QFileIconProvider::DontUseCustomDirectoryIcons
+ option in the icon provider accordingly.
+
+ \sa resolveSymlinks
+*/
+
+/*!
+ \since 5.14
+ Sets the given \a option to be enabled if \a on is true; otherwise,
+ clears the given \a option.
+
+ Options should be set before changing properties.
+
+ \sa options, testOption()
+*/
+void QFileSystemModel::setOption(Option option, bool on)
+{
+ QFileSystemModel::Options previousOptions = options();
+ setOptions(previousOptions.setFlag(option, on));
+}
+
+/*!
+ \since 5.14
+
+ Returns \c true if the given \a option is enabled; otherwise, returns
+ false.
+
+ \sa options, setOption()
+*/
+bool QFileSystemModel::testOption(Option option) const
+{
+ return options().testFlag(option);
+}
+
+/*!
+ \property QFileSystemModel::options
+ \brief the various options that affect the model
+ \since 5.14
+
+ By default, all options are disabled.
+
+ Options should be set before changing properties.
+
+ \sa setOption(), testOption()
+*/
+void QFileSystemModel::setOptions(Options options)
+{
+ const Options changed = (options ^ QFileSystemModel::options());
+
+ if (changed.testFlag(DontResolveSymlinks))
+ setResolveSymlinks(!options.testFlag(DontResolveSymlinks));
+
+#if QT_CONFIG(filesystemwatcher)
+ Q_D(QFileSystemModel);
+ if (changed.testFlag(DontWatchForChanges))
+ d->fileInfoGatherer.setWatching(!options.testFlag(DontWatchForChanges));
+#endif
+
+ if (changed.testFlag(DontUseCustomDirectoryIcons)) {
+ if (auto provider = iconProvider()) {
+ QFileIconProvider::Options providerOptions = provider->options();
+ providerOptions.setFlag(QFileIconProvider::DontUseCustomDirectoryIcons,
+ options.testFlag(QFileSystemModel::DontUseCustomDirectoryIcons));
+ provider->setOptions(providerOptions);
+ } else {
+ qWarning("Setting QFileSystemModel::DontUseCustomDirectoryIcons has no effect when no provider is used");
+ }
+ }
+}
+
+QFileSystemModel::Options QFileSystemModel::options() const
+{
+ QFileSystemModel::Options result;
+ result.setFlag(DontResolveSymlinks, !resolveSymlinks());
+#if QT_CONFIG(filesystemwatcher)
+ Q_D(const QFileSystemModel);
+ result.setFlag(DontWatchForChanges, !d->fileInfoGatherer.isWatching());
+#else
+ result.setFlag(DontWatchForChanges);
+#endif
+ if (auto provider = iconProvider()) {
+ result.setFlag(DontUseCustomDirectoryIcons,
+ provider->options().testFlag(QFileIconProvider::DontUseCustomDirectoryIcons));
+ }
+ return result;
+}
+
+/*!
Returns the path of the item stored in the model under the
\a index given.
*/
@@ -1509,6 +1610,8 @@ QDir::Filters QFileSystemModel::filter() const
This is only relevant on Windows.
By default, this property is \c true.
+
+ \sa QFileSystemModel::Options
*/
void QFileSystemModel::setResolveSymlinks(bool enable)
{
diff --git a/src/widgets/dialogs/qfilesystemmodel.h b/src/widgets/dialogs/qfilesystemmodel.h
index c2c8b8818e..b0f289dfcd 100644
--- a/src/widgets/dialogs/qfilesystemmodel.h
+++ b/src/widgets/dialogs/qfilesystemmodel.h
@@ -61,6 +61,7 @@ class Q_WIDGETS_EXPORT QFileSystemModel : public QAbstractItemModel
Q_PROPERTY(bool resolveSymlinks READ resolveSymlinks WRITE setResolveSymlinks)
Q_PROPERTY(bool readOnly READ isReadOnly WRITE setReadOnly)
Q_PROPERTY(bool nameFilterDisables READ nameFilterDisables WRITE setNameFilterDisables)
+ Q_PROPERTY(Options options READ options WRITE setOptions)
Q_SIGNALS:
void rootPathChanged(const QString &newPath);
@@ -75,6 +76,15 @@ public:
FilePermissions = Qt::UserRole + 3
};
+ enum Option
+ {
+ DontWatchForChanges = 0x00000001,
+ DontResolveSymlinks = 0x00000002,
+ DontUseCustomDirectoryIcons = 0x00000004
+ };
+ Q_ENUM(Option)
+ Q_DECLARE_FLAGS(Options, Option)
+
explicit QFileSystemModel(QObject *parent = nullptr);
~QFileSystemModel();
@@ -129,6 +139,11 @@ public:
void setNameFilters(const QStringList &filters);
QStringList nameFilters() const;
+ void setOption(Option option, bool on = true);
+ bool testOption(Option option) const;
+ void setOptions(Options options);
+ Options options() const;
+
QString filePath(const QModelIndex &index) const;
bool isDir(const QModelIndex &index) const;
qint64 size(const QModelIndex &index) const;
@@ -165,6 +180,8 @@ inline QString QFileSystemModel::fileName(const QModelIndex &aindex) const
inline QIcon QFileSystemModel::fileIcon(const QModelIndex &aindex) const
{ return qvariant_cast<QIcon>(aindex.data(Qt::DecorationRole)); }
+Q_DECLARE_OPERATORS_FOR_FLAGS(QFileSystemModel::Options)
+
QT_END_NAMESPACE
#endif // QFILESYSTEMMODEL_H
diff --git a/src/widgets/dialogs/qwizard.cpp b/src/widgets/dialogs/qwizard.cpp
index 4d28dda7c7..7558054da5 100644
--- a/src/widgets/dialogs/qwizard.cpp
+++ b/src/widgets/dialogs/qwizard.cpp
@@ -1336,7 +1336,7 @@ void QWizardPrivate::updateMinMaxSizes(const QWizardLayoutInfo &info)
int extraHeight = 0;
#if QT_CONFIG(style_windowsvista)
if (isVistaThemeEnabled())
- extraHeight = vistaHelper->titleBarSize() + vistaHelper->topOffset();
+ extraHeight = vistaHelper->titleBarSize() + vistaHelper->topOffset(q);
#endif
QSize minimumSize = mainLayout->totalMinimumSize() + QSize(0, extraHeight);
QSize maximumSize = mainLayout->totalMaximumSize();
@@ -1595,8 +1595,8 @@ bool QWizardPrivate::handleAeroStyleChange()
bool vistaMargins = false;
if (isVistaThemeEnabled()) {
- const int topOffset = vistaHelper->topOffset();
- const int topPadding = vistaHelper->topPadding();
+ const int topOffset = vistaHelper->topOffset(q);
+ const int topPadding = vistaHelper->topPadding(q);
if (isVistaThemeEnabled(QVistaHelper::VistaAero)) {
if (isWindow) {
vistaHelper->setDWMTitleBar(QVistaHelper::ExtendedTitleBar);
@@ -2892,7 +2892,7 @@ void QWizard::setPixmap(WizardPixmap which, const QPixmap &pixmap)
Returns the pixmap set for role \a which.
By default, the only pixmap that is set is the BackgroundPixmap on
- \macos.
+ \macos version 10.13 and earlier.
\sa QWizardPage::pixmap(), {Elements of a Wizard Page}
*/
@@ -3214,7 +3214,7 @@ void QWizard::resizeEvent(QResizeEvent *event)
int heightOffset = 0;
#if QT_CONFIG(style_windowsvista)
if (d->isVistaThemeEnabled()) {
- heightOffset = d->vistaHelper->topOffset();
+ heightOffset = d->vistaHelper->topOffset(this);
if (d->isVistaThemeEnabled(QVistaHelper::VistaAero))
heightOffset += d->vistaHelper->titleBarSize();
}
@@ -3246,7 +3246,7 @@ void QWizard::paintEvent(QPaintEvent * event)
if (d->isVistaThemeEnabled(QVistaHelper::VistaBasic)) {
QPainter painter(this);
QColor color = d->vistaHelper->basicWindowFrameColor();
- painter.fillRect(0, 0, width(), QVistaHelper::topOffset(), color);
+ painter.fillRect(0, 0, width(), QVistaHelper::topOffset(this), color);
}
d->vistaHelper->paintEvent(event);
}
diff --git a/src/widgets/dialogs/qwizard_win.cpp b/src/widgets/dialogs/qwizard_win.cpp
index 95f8f6a878..47ac41a791 100644
--- a/src/widgets/dialogs/qwizard_win.cpp
+++ b/src/widgets/dialogs/qwizard_win.cpp
@@ -87,7 +87,7 @@ QVistaBackButton::QVistaBackButton(QWidget *widget)
QSize QVistaBackButton::sizeHint() const
{
ensurePolished();
- int size = int(QStyleHelper::dpiScaled(32));
+ int size = int(QStyleHelper::dpiScaled(32, this));
int width = size, height = size;
return QSize(width, height);
}
@@ -156,7 +156,7 @@ QVistaHelper::QVistaHelper(QWizard *wizard)
backButton_ = new QVistaBackButton(wizard);
backButton_->hide();
- iconSpacing = QStyleHelper::dpiScaled(7);
+ iconSpacing = QStyleHelper::dpiScaled(7, wizard);
}
QVistaHelper::~QVistaHelper()
@@ -229,7 +229,7 @@ bool QVistaHelper::setDWMTitleBar(TitleBarChangeType type)
if (type == NormalTitleBar)
mar.cyTopHeight = 0;
else
- mar.cyTopHeight = (titleBarSize() + topOffset()) * QVistaHelper::m_devicePixelRatio;
+ mar.cyTopHeight = (titleBarSize() + topOffset(wizard)) * QVistaHelper::m_devicePixelRatio;
if (const HWND wizardHandle = wizardHWND())
if (SUCCEEDED(DwmExtendFrameIntoClientArea(wizardHandle, &mar)))
value = true;
@@ -275,7 +275,7 @@ void QVistaHelper::drawTitleBar(QPainter *painter)
if (vistaState() == VistaAero && isWindow)
drawBlackRect(QRect(0, 0, wizard->width(),
- titleBarSize() + topOffset()), hdc);
+ titleBarSize() + topOffset(wizard)), hdc);
// The button is positioned in QWizardPrivate::handleAeroStyleChange(),
// all calculation is relative to it.
const int btnTop = backButton_->mapToParent(QPoint()).y();
@@ -293,7 +293,7 @@ void QVistaHelper::drawTitleBar(QPainter *painter)
int glowOffset = 0;
if (vistaState() == VistaAero) {
- glowOffset = glowSize();
+ glowOffset = glowSize(wizard);
textHeight += 2 * glowOffset;
textWidth += 2 * glowOffset;
}
@@ -314,10 +314,10 @@ void QVistaHelper::drawTitleBar(QPainter *painter)
const QIcon windowIcon = wizard->windowIcon();
if (!windowIcon.isNull()) {
- const int size = QVistaHelper::iconSize();
+ const int size = QVistaHelper::iconSize(wizard);
const int iconLeft = (wizard->layoutDirection() == Qt::LeftToRight
- ? leftMargin()
- : wizard->width() - leftMargin() - size);
+ ? leftMargin(wizard)
+ : wizard->width() - leftMargin(wizard) - size);
const QPoint pos(origin.x() + iconLeft, origin.y() + verticalCenter - size / 2);
const QPoint posDp = pos * QVistaHelper::m_devicePixelRatio;
@@ -427,7 +427,7 @@ void QVistaHelper::resizeEvent(QResizeEvent * event)
{
Q_UNUSED(event);
rtTop = QRect (0, 0, wizard->width(), frameSize());
- int height = captionSize() + topOffset();
+ int height = captionSize() + topOffset(wizard);
if (vistaState() == VistaBasic)
height -= titleBarSize();
rtTitle = QRect (0, frameSize(), wizard->width(), height);
@@ -637,7 +637,7 @@ bool QVistaHelper::drawTitleText(QPainter *painter, const QString &text, const Q
RECT rctext ={0,0, rectDp.width(), rectDp.height()};
dto.dwFlags = DTT_COMPOSITED|DTT_GLOWSIZE;
- dto.iGlowSize = glowSize();
+ dto.iGlowSize = glowSize(wizard);
DrawThemeTextEx(hTheme, dcMem, 0, 0, reinterpret_cast<LPCWSTR>(text.utf16()), -1, uFormat, &rctext, &dto );
BitBlt(hdc, rectDp.left(), rectDp.top(), rectDp.width(), rectDp.height(), dcMem, 0, 0, SRCCOPY);
@@ -714,27 +714,27 @@ int QVistaHelper::captionSizeDp()
int QVistaHelper::titleOffset()
{
- int iconOffset = wizard ->windowIcon().isNull() ? 0 : iconSize() + iconSpacing;
- return leftMargin() + iconOffset;
+ int iconOffset = wizard ->windowIcon().isNull() ? 0 : iconSize(wizard) + iconSpacing;
+ return leftMargin(wizard) + iconOffset;
}
-int QVistaHelper::iconSize()
+int QVistaHelper::iconSize(const QPaintDevice *device)
{
- return QStyleHelper::dpiScaled(16); // Standard Aero
+ return QStyleHelper::dpiScaled(16, device); // Standard Aero
}
-int QVistaHelper::glowSize()
+int QVistaHelper::glowSize(const QPaintDevice *device)
{
- return QStyleHelper::dpiScaled(10);
+ return QStyleHelper::dpiScaled(10, device);
}
-int QVistaHelper::topOffset()
+int QVistaHelper::topOffset(const QPaintDevice *device)
{
if (vistaState() != VistaAero)
return titleBarSize() + 3;
static const int aeroOffset =
QOperatingSystemVersion::current() < QOperatingSystemVersion::Windows8 ?
- QStyleHelper::dpiScaled(4) : QStyleHelper::dpiScaled(13);
+ QStyleHelper::dpiScaled(4, device) : QStyleHelper::dpiScaled(13, device);
return aeroOffset + titleBarSize();
}
diff --git a/src/widgets/dialogs/qwizard_win_p.h b/src/widgets/dialogs/qwizard_win_p.h
index b3796e3f48..2469496b61 100644
--- a/src/widgets/dialogs/qwizard_win_p.h
+++ b/src/widgets/dialogs/qwizard_win_p.h
@@ -108,10 +108,10 @@ public:
static VistaState vistaState();
static int titleBarSize() { return QVistaHelper::titleBarSizeDp() / QVistaHelper::m_devicePixelRatio; }
static int titleBarSizeDp() { return QVistaHelper::frameSizeDp() + QVistaHelper::captionSizeDp(); }
- static int topPadding() { // padding under text
- return int(QStyleHelper::dpiScaled(4));
+ static int topPadding(const QPaintDevice *device) { // padding under text
+ return int(QStyleHelper::dpiScaled(4, device));
}
- static int topOffset();
+ static int topOffset(const QPaintDevice *device);
static HDC backingStoreDC(const QWidget *wizard, QPoint *offset);
@@ -125,10 +125,12 @@ private:
static int captionSize() { return QVistaHelper::captionSizeDp() / QVistaHelper::m_devicePixelRatio; }
static int captionSizeDp();
- static int backButtonSize() { return int(QStyleHelper::dpiScaled(30)); }
- static int iconSize();
- static int glowSize();
- int leftMargin() { return backButton_->isVisible() ? backButtonSize() + iconSpacing : 0; }
+ static int backButtonSize(const QPaintDevice *device)
+ { return int(QStyleHelper::dpiScaled(30, device)); }
+ static int iconSize(const QPaintDevice *device);
+ static int glowSize(const QPaintDevice *device);
+ int leftMargin(const QPaintDevice *device)
+ { return backButton_->isVisible() ? backButtonSize(device) + iconSpacing : 0; }
int titleOffset();
void drawTitleBar(QPainter *painter);