summaryrefslogtreecommitdiffstats
path: root/src/widgets/dialogs
diff options
context:
space:
mode:
authorOswald Buddenhagen <oswald.buddenhagen@digia.com>2014-02-19 10:06:25 +0100
committerOswald Buddenhagen <oswald.buddenhagen@digia.com>2014-02-19 10:06:25 +0100
commit30fd22b9574def54726e7b193127cc0c901c1b4c (patch)
tree96dfc923044db0515064ba39d052d9ed577e3e40 /src/widgets/dialogs
parentd7b0581c1c2ef60c08d238dae39298af6904918f (diff)
parent6aa09bbce59828d028f6d1e81d2bfc6ba537aae1 (diff)
Merge remote-tracking branch 'origin/dev' into stable
Diffstat (limited to 'src/widgets/dialogs')
-rw-r--r--src/widgets/dialogs/qcolordialog.cpp35
-rw-r--r--src/widgets/dialogs/qcolordialog_p.h2
-rw-r--r--src/widgets/dialogs/qfiledialog.cpp5
-rw-r--r--src/widgets/dialogs/qfileinfogatherer.cpp2
-rw-r--r--src/widgets/dialogs/qfilesystemmodel.cpp2
-rw-r--r--src/widgets/dialogs/qfontdialog.cpp6
-rw-r--r--src/widgets/dialogs/qinputdialog.cpp9
-rw-r--r--src/widgets/dialogs/qmessagebox.cpp16
-rw-r--r--src/widgets/dialogs/qmessagebox.h7
-rw-r--r--src/widgets/dialogs/qwizard.cpp97
-rw-r--r--src/widgets/dialogs/qwizard.h3
-rw-r--r--src/widgets/dialogs/qwizard_win.cpp50
-rw-r--r--src/widgets/dialogs/qwizard_win_p.h4
13 files changed, 163 insertions, 75 deletions
diff --git a/src/widgets/dialogs/qcolordialog.cpp b/src/widgets/dialogs/qcolordialog.cpp
index 2e6518dd17..8866a3e97e 100644
--- a/src/widgets/dialogs/qcolordialog.cpp
+++ b/src/widgets/dialogs/qcolordialog.cpp
@@ -66,6 +66,8 @@
#include "qscreen.h"
#include "qcursor.h"
+#include <algorithm>
+
QT_BEGIN_NAMESPACE
//////////// QWellArray BEGIN
@@ -758,13 +760,9 @@ void QColorLuminancePicker::paintEvent(QPaintEvent *)
int y;
uint *pixel = (uint *) img.scanLine(0);
for (y = 0; y < hi; y++) {
- const uint *end = pixel + wi;
- while (pixel < end) {
- QColor c;
- c.setHsv(hue, sat, y2val(y+coff));
- *pixel = c.rgb();
- ++pixel;
- }
+ uint *end = pixel + wi;
+ std::fill(pixel, end, QColor::fromHsv(hue, sat, y2val(y + coff)).rgb());
+ pixel = end;
}
pix = new QPixmap(QPixmap::fromImage(img));
}
@@ -907,10 +905,8 @@ public:
QColSpinBox(QWidget *parent)
: QSpinBox(parent) { setRange(0, 255); }
void setValue(int i) {
- bool block = signalsBlocked();
- blockSignals(true);
+ const QSignalBlocker blocker(this);
QSpinBox::setValue(i);
- blockSignals(block);
}
};
@@ -1393,7 +1389,7 @@ void QColorShower::setRgb(QRgb rgb)
void QColorShower::setHsv(int h, int s, int v)
{
if (h < -1 || (uint)s > 255 || (uint)v > 255)
- return;
+ return;
rgbOriginal = false;
hue = h; val = v; sat = s;
@@ -1794,6 +1790,21 @@ void QColorDialogPrivate::retranslateStrings()
cs->retranslateStrings();
}
+bool QColorDialogPrivate::canBeNativeDialog() const
+{
+ Q_Q(const QColorDialog);
+ if (nativeDialogInUse)
+ return true;
+ if (q->testAttribute(Qt::WA_DontShowOnScreen))
+ return false;
+ if (q->options() & QColorDialog::DontUseNativeDialog)
+ return false;
+
+ QLatin1String staticName(QColorDialog::staticMetaObject.className());
+ QLatin1String dynamicName(q->metaObject()->className());
+ return (staticName == dynamicName);
+}
+
static const Qt::WindowFlags DefaultWindowFlags =
Qt::Dialog | Qt::WindowTitleHint | Qt::MSWindowsFixedSizeDialogHint
| Qt::WindowSystemMenuHint | Qt::WindowCloseButtonHint;
@@ -2196,13 +2207,13 @@ bool QColorDialogPrivate::handleColorPickingKeyPress(QKeyEvent *e)
void QColorDialog::done(int result)
{
Q_D(QColorDialog);
- QDialog::done(result);
if (result == Accepted) {
d->selectedQColor = d->currentQColor();
emit colorSelected(d->selectedQColor);
} else {
d->selectedQColor = QColor();
}
+ QDialog::done(result);
if (d->receiverToDisconnectOnClose) {
disconnect(this, SIGNAL(colorSelected(QColor)),
d->receiverToDisconnectOnClose, d->memberToDisconnectOnClose);
diff --git a/src/widgets/dialogs/qcolordialog_p.h b/src/widgets/dialogs/qcolordialog_p.h
index f58a9200db..72c3b0e3cd 100644
--- a/src/widgets/dialogs/qcolordialog_p.h
+++ b/src/widgets/dialogs/qcolordialog_p.h
@@ -110,6 +110,8 @@ public:
bool handleColorPickingMouseButtonRelease(QMouseEvent *e);
bool handleColorPickingKeyPress(QKeyEvent *e);
+ bool canBeNativeDialog() const;
+
QWellArray *custom;
QWellArray *standard;
diff --git a/src/widgets/dialogs/qfiledialog.cpp b/src/widgets/dialogs/qfiledialog.cpp
index 998866c039..1c580ce143 100644
--- a/src/widgets/dialogs/qfiledialog.cpp
+++ b/src/widgets/dialogs/qfiledialog.cpp
@@ -1729,7 +1729,7 @@ int QFileDialogPrivate::maxNameLength(const QString &path)
{
#if defined(Q_OS_UNIX)
return ::pathconf(QFile::encodeName(path).data(), _PC_NAME_MAX);
-#elif defined(Q_OS_WINCE)
+#elif defined(Q_OS_WINCE) || defined(Q_OS_WINRT)
Q_UNUSED(path);
return MAX_PATH;
#elif defined(Q_OS_WIN)
@@ -2627,9 +2627,8 @@ void QFileDialog::accept()
// special case for ".."
if (lineEditText == QLatin1String("..")) {
d->_q_navigateToParent();
- bool block = d->qFileDialogUi->fileNameEdit->blockSignals(true);
+ const QSignalBlocker blocker(d->qFileDialogUi->fileNameEdit);
d->lineEdit()->selectAll();
- d->qFileDialogUi->fileNameEdit->blockSignals(block);
return;
}
diff --git a/src/widgets/dialogs/qfileinfogatherer.cpp b/src/widgets/dialogs/qfileinfogatherer.cpp
index c06ef0c474..b08cc798e5 100644
--- a/src/widgets/dialogs/qfileinfogatherer.cpp
+++ b/src/widgets/dialogs/qfileinfogatherer.cpp
@@ -315,7 +315,7 @@ void QFileInfoGatherer::getFileInfos(const QString &path, const QStringList &fil
dirIt.next();
fileInfo = dirIt.fileInfo();
allFiles.append(fileInfo.fileName());
- fetch(fileInfo, base, firstTime, updatedFiles, path);
+ fetch(fileInfo, base, firstTime, updatedFiles, path);
}
if (!allFiles.isEmpty())
emit newListOfFiles(path, allFiles);
diff --git a/src/widgets/dialogs/qfilesystemmodel.cpp b/src/widgets/dialogs/qfilesystemmodel.cpp
index fa6306005b..bda448bde3 100644
--- a/src/widgets/dialogs/qfilesystemmodel.cpp
+++ b/src/widgets/dialogs/qfilesystemmodel.cpp
@@ -1715,7 +1715,7 @@ QFileSystemModelPrivate::QFileSystemNode* QFileSystemModelPrivate::addNode(QFile
#ifndef QT_NO_FILESYSTEMWATCHER
node->populate(info);
#endif
-#if defined(Q_OS_WIN) && !defined(Q_OS_WINCE)
+#if defined(Q_OS_WIN) && !defined(Q_OS_WINCE) && !defined(Q_OS_WINRT)
//The parentNode is "" so we are listing the drives
if (parentNode->fileName.isEmpty()) {
wchar_t name[MAX_PATH + 1];
diff --git a/src/widgets/dialogs/qfontdialog.cpp b/src/widgets/dialogs/qfontdialog.cpp
index d908a683a9..94e96a52c5 100644
--- a/src/widgets/dialogs/qfontdialog.cpp
+++ b/src/widgets/dialogs/qfontdialog.cpp
@@ -632,12 +632,11 @@ void QFontDialogPrivate::updateSizes()
}
sizeList->setCurrentItem(current);
- sizeEdit->blockSignals(true);
+ const QSignalBlocker blocker(sizeEdit);
sizeEdit->setText((smoothScalable ? QString::number(size) : sizeList->currentText()));
if (q->style()->styleHint(QStyle::SH_FontDialog_SelectAssociatedText, 0, q)
&& sizeList->hasFocus())
sizeEdit->selectAll();
- sizeEdit->blockSignals(false);
} else {
sizeEdit->clear();
}
@@ -750,9 +749,8 @@ void QFontDialogPrivate::_q_sizeChanged(const QString &s)
if (sizeList->text(i).toInt() >= this->size)
break;
}
- sizeList->blockSignals(true);
+ const QSignalBlocker blocker(sizeList);
sizeList->setCurrentItem(i);
- sizeList->blockSignals(false);
}
_q_updateSample();
}
diff --git a/src/widgets/dialogs/qinputdialog.cpp b/src/widgets/dialogs/qinputdialog.cpp
index 4eec2eb3e2..10d693b4a3 100644
--- a/src/widgets/dialogs/qinputdialog.cpp
+++ b/src/widgets/dialogs/qinputdialog.cpp
@@ -771,10 +771,11 @@ void QInputDialog::setComboBoxItems(const QStringList &items)
Q_D(QInputDialog);
d->ensureComboBox();
- d->comboBox->blockSignals(true);
- d->comboBox->clear();
- d->comboBox->addItems(items);
- d->comboBox->blockSignals(false);
+ {
+ const QSignalBlocker blocker(d->comboBox);
+ d->comboBox->clear();
+ d->comboBox->addItems(items);
+ }
if (inputMode() == TextInput)
d->chooseRightTextInputWidget();
diff --git a/src/widgets/dialogs/qmessagebox.cpp b/src/widgets/dialogs/qmessagebox.cpp
index ee2ef409d8..3080d5f1e8 100644
--- a/src/widgets/dialogs/qmessagebox.cpp
+++ b/src/widgets/dialogs/qmessagebox.cpp
@@ -73,7 +73,7 @@
QT_BEGIN_NAMESPACE
-#ifdef Q_OS_WIN
+#if defined(Q_OS_WIN) && !defined(Q_OS_WINRT)
HMENU qt_getWindowsSystemMenu(const QWidget *w)
{
if (QWindow *window = QApplicationPrivate::windowForWidget(w))
@@ -209,7 +209,7 @@ public:
void init(const QString &title = QString(), const QString &text = QString());
void setupLayout();
void _q_buttonClicked(QAbstractButton *);
- void _q_clicked(QMessageDialogOptions::StandardButton button, QMessageDialogOptions::ButtonRole role);
+ void _q_clicked(QPlatformDialogHelper::StandardButton button, QPlatformDialogHelper::ButtonRole role);
QAbstractButton *findButton(int button0, int button1, int button2, int flags);
void addOldButtons(int button0, int button1, int button2);
@@ -524,7 +524,7 @@ void QMessageBoxPrivate::_q_buttonClicked(QAbstractButton *button)
}
}
-void QMessageBoxPrivate::_q_clicked(QMessageDialogOptions::StandardButton button, QMessageDialogOptions::ButtonRole role)
+void QMessageBoxPrivate::_q_clicked(QPlatformDialogHelper::StandardButton button, QPlatformDialogHelper::ButtonRole role)
{
Q_UNUSED(role);
Q_Q(QMessageBox);
@@ -1620,7 +1620,7 @@ void QMessageBox::showEvent(QShowEvent *e)
QAccessibleEvent event(this, QAccessible::Alert);
QAccessible::updateAccessibility(&event);
#endif
-#ifdef Q_OS_WIN
+#if defined(Q_OS_WIN) && !defined(Q_OS_WINRT)
if (const HMENU systemMenu = qt_getWindowsSystemMenu(this)) {
EnableMenuItem(systemMenu, SC_CLOSE, d->detectedEscapeButton ?
MF_BYCOMMAND|MF_ENABLED : MF_BYCOMMAND|MF_GRAYED);
@@ -2697,8 +2697,8 @@ QPixmap QMessageBoxPrivate::standardIcon(QMessageBox::Icon icon, QMessageBox *mb
void QMessageBoxPrivate::initHelper(QPlatformDialogHelper *h)
{
Q_Q(QMessageBox);
- QObject::connect(h, SIGNAL(clicked(QMessageDialogOptions::StandardButton, QMessageDialogOptions::ButtonRole)),
- q, SLOT(_q_clicked(QMessageDialogOptions::StandardButton, QMessageDialogOptions::ButtonRole)));
+ QObject::connect(h, SIGNAL(clicked(QPlatformDialogHelper::StandardButton, QPlatformDialogHelper::ButtonRole)),
+ q, SLOT(_q_clicked(QPlatformDialogHelper::StandardButton, QPlatformDialogHelper::ButtonRole)));
static_cast<QPlatformMessageDialogHelper *>(h)->setOptions(options);
}
@@ -2719,9 +2719,9 @@ static QMessageDialogOptions::Icon helperIcon(QMessageBox::Icon i)
return QMessageDialogOptions::NoIcon;
}
-static QMessageDialogOptions::StandardButtons helperStandardButtons(QMessageBox * q)
+static QPlatformDialogHelper::StandardButtons helperStandardButtons(QMessageBox * q)
{
- QMessageDialogOptions::StandardButtons buttons(int(q->standardButtons()));
+ QPlatformDialogHelper::StandardButtons buttons(int(q->standardButtons()));
return buttons;
}
diff --git a/src/widgets/dialogs/qmessagebox.h b/src/widgets/dialogs/qmessagebox.h
index c5598a8f1d..5fae174fe1 100644
--- a/src/widgets/dialogs/qmessagebox.h
+++ b/src/widgets/dialogs/qmessagebox.h
@@ -72,6 +72,7 @@ class Q_WIDGETS_EXPORT QMessageBox : public QDialog
public:
enum Icon {
+ // keep this in sync with QMessageDialogOptions::Icon
NoIcon = 0,
Information = 1,
Warning = 2,
@@ -80,7 +81,7 @@ public:
};
enum ButtonRole {
- // keep this in sync with QDialogButtonBox::ButtonRole
+ // keep this in sync with QDialogButtonBox::ButtonRole and QPlatformDialogHelper::ButtonRole
InvalidRole = -1,
AcceptRole,
RejectRole,
@@ -96,7 +97,7 @@ public:
};
enum StandardButton {
- // keep this in sync with QDialogButtonBox::StandardButton and QMessageDialogOptions::StandardButton
+ // keep this in sync with QDialogButtonBox::StandardButton and QPlatformDialogHelper::StandardButton
NoButton = 0x00000000,
Ok = 0x00000400,
Save = 0x00000800,
@@ -309,7 +310,7 @@ protected:
private:
Q_PRIVATE_SLOT(d_func(), void _q_buttonClicked(QAbstractButton *))
- Q_PRIVATE_SLOT(d_func(), void _q_clicked(QMessageDialogOptions::StandardButton, QMessageDialogOptions::ButtonRole))
+ Q_PRIVATE_SLOT(d_func(), void _q_clicked(QPlatformDialogHelper::StandardButton, QPlatformDialogHelper::ButtonRole))
Q_DISABLE_COPY(QMessageBox)
Q_DECLARE_PRIVATE(QMessageBox)
diff --git a/src/widgets/dialogs/qwizard.cpp b/src/widgets/dialogs/qwizard.cpp
index a667f299e8..b294e98c30 100644
--- a/src/widgets/dialogs/qwizard.cpp
+++ b/src/widgets/dialogs/qwizard.cpp
@@ -76,6 +76,7 @@ extern bool qt_wince_is_mobile(); //defined in qguifunctions_wce.cpp
#endif
#include <string.h> // for memset()
+#include <algorithm>
QT_BEGIN_NAMESPACE
@@ -129,22 +130,41 @@ static bool objectInheritsXAndXIsCloserThanY(const QObject *object, const QByteA
return false;
}
-const int NFallbackDefaultProperties = 7;
-
const struct {
- const char *className;
- const char *property;
- const char *changedSignal;
-} fallbackProperties[NFallbackDefaultProperties] = {
+ const char className[16];
+ const char property[13];
+} fallbackProperties[] = {
// If you modify this list, make sure to update the documentation (and the auto test)
- { "QAbstractButton", "checked", SIGNAL(toggled(bool)) },
- { "QAbstractSlider", "value", SIGNAL(valueChanged(int)) },
- { "QComboBox", "currentIndex", SIGNAL(currentIndexChanged(int)) },
- { "QDateTimeEdit", "dateTime", SIGNAL(dateTimeChanged(QDateTime)) },
- { "QLineEdit", "text", SIGNAL(textChanged(QString)) },
- { "QListWidget", "currentRow", SIGNAL(currentRowChanged(int)) },
- { "QSpinBox", "value", SIGNAL(valueChanged(int)) }
+ { "QAbstractButton", "checked" },
+ { "QAbstractSlider", "value" },
+ { "QComboBox", "currentIndex" },
+ { "QDateTimeEdit", "dateTime" },
+ { "QLineEdit", "text" },
+ { "QListWidget", "currentRow" },
+ { "QSpinBox", "value" },
};
+const size_t NFallbackDefaultProperties = sizeof fallbackProperties / sizeof *fallbackProperties;
+
+static const char *changed_signal(int which)
+{
+ // since it might expand to a runtime function call (to
+ // qFlagLocations()), we cannot store the result of SIGNAL() in a
+ // character array and expect it to be statically initialized. To
+ // avoid the relocations caused by a char pointer table, use a
+ // switch statement:
+ switch (which) {
+ case 0: return SIGNAL(toggled(bool));
+ case 1: return SIGNAL(valueChanged(int));
+ case 2: return SIGNAL(currentIndexChanged(int));
+ case 3: return SIGNAL(dateTimeChanged(QDateTime));
+ case 4: return SIGNAL(textChanged(QString));
+ case 5: return SIGNAL(currentRowChanged(int));
+ case 6: return SIGNAL(valueChanged(int));
+ };
+ Q_STATIC_ASSERT(7 == NFallbackDefaultProperties);
+ Q_UNREACHABLE();
+ return 0;
+}
class QWizardDefaultProperty
{
@@ -542,6 +562,7 @@ public:
, canContinue(false)
, canFinish(false)
, disableUpdatesCount(0)
+ , wizStyle(QWizard::ClassicStyle)
, opts(0)
, buttonsHaveCustomLayout(false)
, titleFmt(Qt::AutoText)
@@ -551,10 +572,12 @@ public:
, headerWidget(0)
, watermarkLabel(0)
, sideWidget(0)
+ , pageFrame(0)
, titleLabel(0)
, subTitleLabel(0)
, bottomRuler(0)
#if !defined(QT_NO_STYLE_WINDOWSVISTA)
+ , vistaHelper(0)
, vistaInitPending(false)
, vistaState(QVistaHelper::Dirty)
, vistaStateChanged(false)
@@ -565,8 +588,7 @@ public:
, maximumWidth(QWIDGETSIZE_MAX)
, maximumHeight(QWIDGETSIZE_MAX)
{
- for (int i = 0; i < QWizard::NButtons; ++i)
- btns[i] = 0;
+ std::fill(btns, btns + QWizard::NButtons, static_cast<QAbstractButton *>(0));
#if !defined(QT_NO_STYLE_WINDOWSVISTA)
if (QSysInfo::WindowsVersion >= QSysInfo::WV_VISTA
@@ -737,10 +759,10 @@ void QWizardPrivate::init()
updateButtonLayout();
- for (int i = 0; i < NFallbackDefaultProperties; ++i)
+ for (uint i = 0; i < NFallbackDefaultProperties; ++i)
defaultPropertyTable.append(QWizardDefaultProperty(fallbackProperties[i].className,
fallbackProperties[i].property,
- fallbackProperties[i].changedSignal));
+ changed_signal(i)));
}
void QWizardPrivate::reset()
@@ -887,9 +909,28 @@ void QWizardPrivate::switchToPage(int newId, Direction direction)
}
// keep in sync with QWizard::WizardButton
-static const char * const buttonSlots[QWizard::NStandardButtons] = {
- SLOT(back()), SLOT(next()), SLOT(next()), SLOT(accept()), SLOT(reject()),
- SIGNAL(helpRequested())
+static const char * buttonSlots(QWizard::WizardButton which)
+{
+ switch (which) {
+ case QWizard::BackButton:
+ return SLOT(back());
+ case QWizard::NextButton:
+ case QWizard::CommitButton:
+ return SLOT(next());
+ case QWizard::FinishButton:
+ return SLOT(accept());
+ case QWizard::CancelButton:
+ return SLOT(reject());
+ case QWizard::HelpButton:
+ return SIGNAL(helpRequested());
+ case QWizard::CustomButton1:
+ case QWizard::CustomButton2:
+ case QWizard::CustomButton3:
+ case QWizard::Stretch:
+ case QWizard::NoButton:
+ Q_UNREACHABLE();
+ };
+ return 0;
};
QWizardLayoutInfo QWizardPrivate::layoutInfoForCurrentPage()
@@ -1405,7 +1446,7 @@ void QWizardPrivate::connectButton(QWizard::WizardButton which) const
{
Q_Q(const QWizard);
if (which < QWizard::NStandardButtons) {
- QObject::connect(btns[which], SIGNAL(clicked()), q, buttonSlots[which]);
+ QObject::connect(btns[which], SIGNAL(clicked()), q, buttonSlots(which));
} else {
QObject::connect(btns[which], SIGNAL(clicked()), q, SLOT(_q_emitCustomButtonClicked()));
}
@@ -1424,6 +1465,11 @@ void QWizardPrivate::updateButtonTexts()
btns[i]->setText(buttonDefaultText(wizStyle, i, this));
}
}
+ // Vista: Add shortcut for 'next'. Note: native dialogs use ALT-Right
+ // even in RTL mode, so do the same, even if it might be counter-intuitive.
+ // The shortcut for 'back' is set in class QVistaBackButton.
+ if (btns[QWizard::NextButton])
+ btns[QWizard::NextButton]->setShortcut(isVistaThemeEnabled() ? QKeySequence(Qt::ALT | Qt::Key_Right) : QKeySequence());
}
void QWizardPrivate::updateButtonLayout()
@@ -1576,7 +1622,7 @@ bool QWizardPrivate::handleAeroStyleChange()
if (isWindow)
vistaHelper->setTitleBarIconAndCaptionVisible(false);
QObject::connect(
- vistaHelper->backButton(), SIGNAL(clicked()), q, buttonSlots[QWizard::BackButton]);
+ vistaHelper->backButton(), SIGNAL(clicked()), q, buttonSlots(QWizard::BackButton));
vistaHelper->backButton()->show();
} else {
q->setMouseTracking(true); // ### original value possibly different
@@ -1666,6 +1712,10 @@ void QWizardPrivate::_q_updateButtonStates()
btn.finish->setVisible(buttonLayoutContains(QWizard::FinishButton)
&& (canFinish || (opts & QWizard::HaveFinishButtonOnEarlyPages)));
+ if (!(opts & QWizard::NoCancelButton))
+ btn.cancel->setVisible(buttonLayoutContains(QWizard::CancelButton)
+ && (canContinue || !(opts & QWizard::NoCancelButtonOnLastPage)));
+
bool useDefault = !(opts & QWizard::NoDefaultButton);
if (QPushButton *nextPush = qobject_cast<QPushButton *>(btn.next))
nextPush->setDefault(canContinue && useDefault && !commitPage);
@@ -2150,6 +2200,7 @@ void QWizardAntiFlickerWidget::paintEvent(QPaintEvent *)
\value HaveCustomButton1 Show the first user-defined button (CustomButton1).
\value HaveCustomButton2 Show the second user-defined button (CustomButton2).
\value HaveCustomButton3 Show the third user-defined button (CustomButton3).
+ \value NoCancelButtonOnLastPage Don't show the \uicontrol Cancel button on the last page.
\sa setOptions(), setOption(), testOption()
*/
@@ -2604,7 +2655,7 @@ void QWizard::setOptions(WizardOptions options)
d->updateButtonLayout();
} else if (changed & (NoBackButtonOnStartPage | NoBackButtonOnLastPage
| HaveNextButtonOnLastPage | HaveFinishButtonOnEarlyPages
- | DisabledBackButtonOnLastPage)) {
+ | DisabledBackButtonOnLastPage | NoCancelButtonOnLastPage)) {
d->_q_updateButtonStates();
}
diff --git a/src/widgets/dialogs/qwizard.h b/src/widgets/dialogs/qwizard.h
index 9dea9a8e6f..51b18e0e8f 100644
--- a/src/widgets/dialogs/qwizard.h
+++ b/src/widgets/dialogs/qwizard.h
@@ -115,7 +115,8 @@ public:
HelpButtonOnRight = 0x00001000,
HaveCustomButton1 = 0x00002000,
HaveCustomButton2 = 0x00004000,
- HaveCustomButton3 = 0x00008000
+ HaveCustomButton3 = 0x00008000,
+ NoCancelButtonOnLastPage = 0x00010000
};
Q_DECLARE_FLAGS(WizardOptions, WizardOption)
diff --git a/src/widgets/dialogs/qwizard_win.cpp b/src/widgets/dialogs/qwizard_win.cpp
index b57614c018..747115984d 100644
--- a/src/widgets/dialogs/qwizard_win.cpp
+++ b/src/widgets/dialogs/qwizard_win.cpp
@@ -117,16 +117,16 @@ enum WIZ_WINDOWTHEMEATTRIBUTETYPE {
#define WIZ_DT_NOPREFIX 0x00000800
enum WIZ_NAVIGATIONPARTS { //NAVIGATIONPARTS
- WIZ_NAV_BACKBUTTON = 1,
- WIZ_NAV_FORWARDBUTTON = 2,
- WIZ_NAV_MENUBUTTON = 3,
+ WIZ_NAV_BACKBUTTON = 1,
+ WIZ_NAV_FORWARDBUTTON = 2,
+ WIZ_NAV_MENUBUTTON = 3,
};
enum WIZ_NAV_BACKBUTTONSTATES { //NAV_BACKBUTTONSTATES
- WIZ_NAV_BB_NORMAL = 1,
- WIZ_NAV_BB_HOT = 2,
- WIZ_NAV_BB_PRESSED = 3,
- WIZ_NAV_BB_DISABLED = 4,
+ WIZ_NAV_BB_NORMAL = 1,
+ WIZ_NAV_BB_HOT = 2,
+ WIZ_NAV_BB_PRESSED = 3,
+ WIZ_NAV_BB_DISABLED = 4,
};
#define WIZ_TMT_CAPTIONFONT (801) //TMT_CAPTIONFONT
@@ -183,6 +183,8 @@ QVistaBackButton::QVistaBackButton(QWidget *widget)
: QAbstractButton(widget)
{
setFocusPolicy(Qt::NoFocus);
+ // Native dialogs use ALT-Left even in RTL mode, so do the same, even if it might be counter-intuitive.
+ setShortcut(QKeySequence(Qt::ALT | Qt::Key_Left));
}
QSize QVistaBackButton::sizeHint() const
@@ -278,8 +280,6 @@ QVistaHelper::~QVistaHelper()
void QVistaHelper::updateCustomMargins(bool vistaMargins)
{
- if (QSysInfo::WindowsVersion >= QSysInfo::WV_WINDOWS8)
- return; // Negative margins are not supported on Windows 8.
if (QWindow *window = wizard->windowHandle()) {
// Reduce top frame to zero since we paint it ourselves.
const QMargins customMargins = vistaMargins ?
@@ -768,6 +768,33 @@ bool QVistaHelper::drawBlackRect(const QRect &rect, HDC hdc)
return value;
}
+#if !defined(_MSC_VER) || _MSC_VER < 1700
+static inline int getWindowBottomMargin()
+{
+ return GetSystemMetrics(SM_CYSIZEFRAME);
+}
+#else // !_MSC_VER || _MSC_VER < 1700
+// QTBUG-36192, GetSystemMetrics(SM_CYSIZEFRAME) returns bogus values
+// for MSVC2012 which leads to the custom margin having no effect since
+// that only works when removing the entire margin.
+static inline int getWindowBottomMargin()
+{
+ RECT rect = {0, 0, 0, 0};
+ AdjustWindowRectEx(&rect, WS_POPUP | WS_CLIPSIBLINGS | WS_CLIPCHILDREN | WS_THICKFRAME | WS_DLGFRAME, FALSE, 0);
+ return qAbs(rect.bottom);
+}
+#endif // _MSC_VER >= 1700
+
+int QVistaHelper::frameSize()
+{
+ return getWindowBottomMargin();
+}
+
+int QVistaHelper::captionSize()
+{
+ return GetSystemMetrics(SM_CYCAPTION);
+}
+
bool QVistaHelper::resolveSymbols()
{
static bool tried = false;
@@ -826,10 +853,7 @@ int QVistaHelper::topOffset()
static const int aeroOffset =
QSysInfo::WindowsVersion == QSysInfo::WV_WINDOWS7 ?
QStyleHelper::dpiScaled(4) : QStyleHelper::dpiScaled(13);
- int result = aeroOffset;
- if (QSysInfo::WindowsVersion < QSysInfo::WV_WINDOWS8)
- result += titleBarSize();
- return result;
+ return aeroOffset + titleBarSize();
}
QT_END_NAMESPACE
diff --git a/src/widgets/dialogs/qwizard_win_p.h b/src/widgets/dialogs/qwizard_win_p.h
index a7713d889b..81514a8950 100644
--- a/src/widgets/dialogs/qwizard_win_p.h
+++ b/src/widgets/dialogs/qwizard_win_p.h
@@ -117,8 +117,8 @@ private:
bool drawTitleText(QPainter *painter, const QString &text, const QRect &rect, HDC hdc);
static bool drawBlackRect(const QRect &rect, HDC hdc);
- static int frameSize() { return GetSystemMetrics(SM_CYSIZEFRAME); }
- static int captionSize() { return GetSystemMetrics(SM_CYCAPTION); }
+ static int frameSize();
+ static int captionSize();
static int backButtonSize() { return int(QStyleHelper::dpiScaled(30)); }
static int iconSize() { return 16; } // Standard Aero