summaryrefslogtreecommitdiffstats
path: root/src/widgets
diff options
context:
space:
mode:
Diffstat (limited to 'src/widgets')
-rw-r--r--src/widgets/dialogs/qcolordialog.cpp100
-rw-r--r--src/widgets/dialogs/qcolordialog.h3
-rw-r--r--src/widgets/dialogs/qcolordialog_p.h5
-rw-r--r--src/widgets/dialogs/qdialog.cpp24
-rw-r--r--src/widgets/dialogs/qdialog_p.h3
-rw-r--r--src/widgets/dialogs/qfiledialog.cpp33
-rw-r--r--src/widgets/dialogs/qfiledialog_p.h2
-rw-r--r--src/widgets/dialogs/qmessagebox.cpp66
-rw-r--r--src/widgets/dialogs/qmessagebox.h1
-rw-r--r--src/widgets/dialogs/qwizard.cpp41
-rw-r--r--src/widgets/doc/qtwidgets.qdocconf2
-rw-r--r--src/widgets/doc/src/widgets-and-layouts/layout.qdoc4
-rw-r--r--src/widgets/doc/src/widgets-tutorial.qdoc2
-rw-r--r--src/widgets/graphicsview/qgraphicsitem.cpp4
-rw-r--r--src/widgets/graphicsview/qgraphicsscene.cpp5
-rw-r--r--src/widgets/graphicsview/qgraphicswidget_p.cpp5
-rw-r--r--src/widgets/itemviews/qabstractitemview.cpp11
-rw-r--r--src/widgets/itemviews/qabstractitemview.h2
-rw-r--r--src/widgets/itemviews/qheaderview.cpp9
-rw-r--r--src/widgets/itemviews/qheaderview.h2
-rw-r--r--src/widgets/itemviews/qlistview.cpp10
-rw-r--r--src/widgets/itemviews/qlistview.h2
-rw-r--r--src/widgets/itemviews/qlistwidget.cpp2
-rw-r--r--src/widgets/itemviews/qtableview.h4
-rw-r--r--src/widgets/itemviews/qtablewidget.cpp2
-rw-r--r--src/widgets/itemviews/qtreeview.cpp45
-rw-r--r--src/widgets/itemviews/qtreeview.h5
-rw-r--r--src/widgets/itemviews/qtreeview_p.h2
-rw-r--r--src/widgets/kernel/qapplication.cpp13
-rw-r--r--src/widgets/kernel/qformlayout.cpp2
-rw-r--r--src/widgets/kernel/qlayout.cpp28
-rw-r--r--src/widgets/kernel/qlayout.h4
-rw-r--r--src/widgets/kernel/qwidget.cpp22
-rw-r--r--src/widgets/kernel/qwidget.h2
-rw-r--r--src/widgets/kernel/qwidget_qpa.cpp6
-rw-r--r--src/widgets/kernel/qwidgetbackingstore_p.h8
-rw-r--r--src/widgets/kernel/qwidgetwindow.cpp11
-rw-r--r--src/widgets/kernel/qwindowcontainer.cpp24
-rw-r--r--src/widgets/kernel/qwindowcontainer_p.h1
-rw-r--r--src/widgets/kernel/win.pri2
-rw-r--r--src/widgets/styles/qandroidstyle.cpp22
-rw-r--r--src/widgets/styles/qcommonstyle.cpp2
-rw-r--r--src/widgets/styles/qmacstyle_mac.mm10
-rw-r--r--src/widgets/styles/qstylesheetstyle.cpp2
-rw-r--r--src/widgets/widgets/qdialogbuttonbox.cpp43
-rw-r--r--src/widgets/widgets/qdockwidget.cpp8
-rw-r--r--src/widgets/widgets/qkeysequenceedit.cpp19
-rw-r--r--src/widgets/widgets/qkeysequenceedit.h4
-rw-r--r--src/widgets/widgets/qkeysequenceedit_p.h5
-rw-r--r--src/widgets/widgets/qlineedit.cpp6
-rw-r--r--src/widgets/widgets/qlineedit_p.cpp13
-rw-r--r--src/widgets/widgets/qlineedit_p.h3
-rw-r--r--src/widgets/widgets/qmdiarea.cpp5
-rw-r--r--src/widgets/widgets/qmdisubwindow.cpp5
-rw-r--r--src/widgets/widgets/qscrollarea.h3
-rw-r--r--src/widgets/widgets/qtabbar.cpp23
-rw-r--r--src/widgets/widgets/qtabbar.h1
-rw-r--r--src/widgets/widgets/qtextedit.cpp15
58 files changed, 443 insertions, 265 deletions
diff --git a/src/widgets/dialogs/qcolordialog.cpp b/src/widgets/dialogs/qcolordialog.cpp
index 8956842493..4c5fb18766 100644
--- a/src/widgets/dialogs/qcolordialog.cpp
+++ b/src/widgets/dialogs/qcolordialog.cpp
@@ -427,6 +427,30 @@ void QWellArray::keyPressEvent(QKeyEvent* e)
//////////// QWellArray END
+// Event filter to be installed on the dialog while in color-picking mode.
+class QColorPickingEventFilter : public QObject {
+public:
+ explicit QColorPickingEventFilter(QColorDialogPrivate *dp, QObject *parent = 0) : QObject(parent), m_dp(dp) {}
+
+ bool eventFilter(QObject *, QEvent *event) Q_DECL_OVERRIDE
+ {
+ switch (event->type()) {
+ case QEvent::MouseMove:
+ return m_dp->handleColorPickingMouseMove(static_cast<QMouseEvent *>(event));
+ case QEvent::MouseButtonRelease:
+ return m_dp->handleColorPickingMouseButtonRelease(static_cast<QMouseEvent *>(event));
+ case QEvent::KeyPress:
+ return m_dp->handleColorPickingKeyPress(static_cast<QKeyEvent *>(event));
+ default:
+ break;
+ }
+ return false;
+ }
+
+private:
+ QColorDialogPrivate *m_dp;
+};
+
/*!
Returns the number of custom colors supported by QColorDialog. All
color dialogs share the same custom colors.
@@ -1518,7 +1542,9 @@ void QColorDialogPrivate::_q_newStandard(int r, int c)
void QColorDialogPrivate::_q_pickScreenColor()
{
Q_Q(QColorDialog);
- screenColorPicking = true;
+ if (!colorPickingEventFilter)
+ colorPickingEventFilter = new QColorPickingEventFilter(this);
+ q->installEventFilter(colorPickingEventFilter);
// If user pushes Escape, the last color before picking will be restored.
beforeScreenColorPicking = cs->currentColor();
/*For some reason, q->grabMouse(Qt::CrossCursor) doesn't change
@@ -1548,7 +1574,7 @@ void QColorDialogPrivate::_q_pickScreenColor()
void QColorDialogPrivate::releaseColorPicking()
{
Q_Q(QColorDialog);
- screenColorPicking = false;
+ q->removeEventFilter(colorPickingEventFilter);
q->releaseMouse();
q->releaseKeyboard();
#ifndef QT_NO_CURSOR
@@ -1570,7 +1596,7 @@ void QColorDialogPrivate::init(const QColor &initial)
// default: use the native dialog if possible. Can be overridden in setOptions()
nativeDialogInUse = (platformColorDialogHelper() != 0);
- screenColorPicking = false;
+ colorPickingEventFilter = 0;
nextCust = 0;
if (!nativeDialogInUse)
@@ -2121,55 +2147,41 @@ void QColorDialog::changeEvent(QEvent *e)
QDialog::changeEvent(e);
}
-/*!
- \reimp
-*/
-void QColorDialog::mouseMoveEvent(QMouseEvent *e)
+bool QColorDialogPrivate::handleColorPickingMouseMove(QMouseEvent *e)
{
- Q_D(QColorDialog);
- if (d->screenColorPicking) {
- setCurrentColor(d->grabScreenColor(e->globalPos()));
- d->lblScreenColorInfo->setText(QColorDialog::tr("Cursor at %1, %2, color: %3\nPress ESC to cancel")
- .arg(e->globalPos().x())
- .arg(e->globalPos().y())
- .arg(currentColor().name()));
- return;
- }
- QDialog::mouseMoveEvent(e);
+ Q_Q(QColorDialog);
+ const QPoint globalPos = e->globalPos();
+ const QColor color = grabScreenColor(globalPos);
+ q->setCurrentColor(color);
+ lblScreenColorInfo->setText(QColorDialog::tr("Cursor at %1, %2, color: %3\nPress ESC to cancel")
+ .arg(globalPos.x()).arg(globalPos.y()).arg(color.name()));
+ return true;
}
-/*!
- \reimp
-*/
-void QColorDialog::mouseReleaseEvent(QMouseEvent *e)
+bool QColorDialogPrivate::handleColorPickingMouseButtonRelease(QMouseEvent *e)
{
- Q_D(QColorDialog);
- if (d->screenColorPicking) {
- setCurrentColor(d->grabScreenColor(e->globalPos()));
- d->releaseColorPicking();
- return;
- }
- QDialog::mouseReleaseEvent(e);
+ Q_Q(QColorDialog);
+ q->setCurrentColor(grabScreenColor(e->globalPos()));
+ releaseColorPicking();
+ return true;
}
-/*!
- \reimp
-*/
-void QColorDialog::keyPressEvent(QKeyEvent *e)
+bool QColorDialogPrivate::handleColorPickingKeyPress(QKeyEvent *e)
{
- Q_D(QColorDialog);
- if (d->screenColorPicking) {
- if (e->key() == Qt::Key_Escape) {
- d->releaseColorPicking();
- d->setCurrentColor(d->beforeScreenColorPicking);
- } else if (e->key() == Qt::Key_Return || e->key() == Qt::Key_Enter) {
- setCurrentColor(d->grabScreenColor(QCursor::pos()));
- d->releaseColorPicking();
- }
- e->accept();
- return;
+ Q_Q(QColorDialog);
+ switch (e->key()) {
+ case Qt::Key_Escape:
+ releaseColorPicking();
+ q->setCurrentColor(beforeScreenColorPicking);
+ break;
+ case Qt::Key_Return:
+ case Qt::Key_Enter:
+ q->setCurrentColor(grabScreenColor(QCursor::pos()));
+ releaseColorPicking();
+ break;
}
- QDialog::keyPressEvent(e);
+ e->accept();
+ return true;
}
/*!
diff --git a/src/widgets/dialogs/qcolordialog.h b/src/widgets/dialogs/qcolordialog.h
index c7a1d6f400..c74ee6720a 100644
--- a/src/widgets/dialogs/qcolordialog.h
+++ b/src/widgets/dialogs/qcolordialog.h
@@ -112,9 +112,6 @@ Q_SIGNALS:
protected:
void changeEvent(QEvent *event);
- virtual void mouseMoveEvent(QMouseEvent *);
- virtual void mouseReleaseEvent(QMouseEvent *);
- virtual void keyPressEvent(QKeyEvent *);
void done(int result);
private:
diff --git a/src/widgets/dialogs/qcolordialog_p.h b/src/widgets/dialogs/qcolordialog_p.h
index 08199cc7c1..f58a9200db 100644
--- a/src/widgets/dialogs/qcolordialog_p.h
+++ b/src/widgets/dialogs/qcolordialog_p.h
@@ -70,6 +70,7 @@ class QLabel;
class QVBoxLayout;
class QPushButton;
class QWellArray;
+class QColorPickingEventFilter;
class QColorDialogPrivate : public QDialogPrivate
{
@@ -105,6 +106,9 @@ public:
void _q_newStandard(int, int);
void _q_pickScreenColor();
void releaseColorPicking();
+ bool handleColorPickingMouseMove(QMouseEvent *e);
+ bool handleColorPickingMouseButtonRelease(QMouseEvent *e);
+ bool handleColorPickingKeyPress(QKeyEvent *e);
QWellArray *custom;
QWellArray *standard;
@@ -125,6 +129,7 @@ public:
int nextCust;
bool smallDisplay;
bool screenColorPicking;
+ QColorPickingEventFilter *colorPickingEventFilter;
QRgb beforeScreenColorPicking;
QSharedPointer<QColorDialogOptions> options;
diff --git a/src/widgets/dialogs/qdialog.cpp b/src/widgets/dialogs/qdialog.cpp
index af352e45c6..d498b077fc 100644
--- a/src/widgets/dialogs/qdialog.cpp
+++ b/src/widgets/dialogs/qdialog.cpp
@@ -52,6 +52,8 @@
#include "qwhatsthis.h"
#include "qmenu.h"
#include "qcursor.h"
+#include "qmessagebox.h"
+#include "qerrormessage.h"
#include <qpa/qplatformtheme.h>
#include "private/qdialog_p.h"
#include "private/qguiapplication_p.h"
@@ -75,6 +77,14 @@ static inline int themeDialogType(const QDialog *dialog)
if (qobject_cast<const QFontDialog *>(dialog))
return QPlatformTheme::FontDialog;
#endif
+#ifndef QT_NO_MESSAGEBOX
+ if (qobject_cast<const QMessageBox *>(dialog))
+ return QPlatformTheme::MessageDialog;
+#endif
+#ifndef QT_NO_ERRORMESSAGE
+ if (qobject_cast<const QErrorMessage *>(dialog))
+ return QPlatformTheme::MessageDialog;
+#endif
return -1;
}
@@ -100,6 +110,17 @@ QPlatformDialogHelper *QDialogPrivate::platformHelper() const
return m_platformHelper;
}
+bool QDialogPrivate::canBeNativeDialog() const
+{
+ QDialogPrivate *ncThis = const_cast<QDialogPrivate *>(this);
+ QDialog *dialog = ncThis->q_func();
+ const int type = themeDialogType(dialog);
+ if (type >= 0)
+ return QGuiApplicationPrivate::platformTheme()
+ ->usePlatformNativeDialog(static_cast<QPlatformTheme::DialogType>(type));
+ return false;
+}
+
QWindow *QDialogPrivate::parentWindow() const
{
if (const QWidget *parent = q_func()->nativeParentWidget())
@@ -697,6 +718,9 @@ void QDialog::closeEvent(QCloseEvent *e)
void QDialog::setVisible(bool visible)
{
Q_D(QDialog);
+ if (!testAttribute(Qt::WA_DontShowOnScreen) && d->canBeNativeDialog() && d->setNativeDialogVisible(visible))
+ return;
+
if (visible) {
if (testAttribute(Qt::WA_WState_ExplicitShowHide) && !testAttribute(Qt::WA_WState_Hidden))
return;
diff --git a/src/widgets/dialogs/qdialog_p.h b/src/widgets/dialogs/qdialog_p.h
index 5064efa35d..8db1b2a27c 100644
--- a/src/widgets/dialogs/qdialog_p.h
+++ b/src/widgets/dialogs/qdialog_p.h
@@ -64,7 +64,7 @@ QT_BEGIN_NAMESPACE
class QSizeGrip;
-class QDialogPrivate : public QWidgetPrivate
+class Q_WIDGETS_EXPORT QDialogPrivate : public QWidgetPrivate
{
Q_DECLARE_PUBLIC(QDialog)
public:
@@ -113,6 +113,7 @@ public:
bool nativeDialogInUse;
QPlatformDialogHelper *platformHelper() const;
+ virtual bool canBeNativeDialog() const;
private:
virtual void initHelper(QPlatformDialogHelper *) {}
diff --git a/src/widgets/dialogs/qfiledialog.cpp b/src/widgets/dialogs/qfiledialog.cpp
index 11ad7c7a5d..1c3a793234 100644
--- a/src/widgets/dialogs/qfiledialog.cpp
+++ b/src/widgets/dialogs/qfiledialog.cpp
@@ -184,6 +184,13 @@ Q_WIDGETS_EXPORT _qt_filedialog_save_file_url_hook qt_filedialog_save_file_url_h
The \l{dialogs/standarddialogs}{Standard Dialogs} example shows
how to use QFileDialog as well as other built-in Qt dialogs.
+ By default, a platform-native file dialog will be used if the platform has
+ one. In that case, the widgets which would otherwise be used to construct the
+ dialog will not be instantiated, so related accessors such as layout() and
+ itemDelegate() will return null. You can set the \l DontUseNativeDialog option to
+ ensure that the widget-based implementation will be used instead of the
+ native dialog.
+
\sa QDir, QFileInfo, QFile, QColorDialog, QFontDialog, {Standard Dialogs Example},
{Application Example}
*/
@@ -243,7 +250,8 @@ Q_WIDGETS_EXPORT _qt_filedialog_save_file_url_hook qt_filedialog_save_file_url_h
\value DontUseNativeDialog Don't use the native file dialog. By
default, the native file dialog is used unless you use a subclass
- of QFileDialog that contains the Q_OBJECT macro.
+ of QFileDialog that contains the Q_OBJECT macro, or the platform
+ does not have a native dialog of the type that you require.
\value ReadOnly Indicates that the model is readonly.
@@ -620,7 +628,8 @@ void QFileDialogPrivate::helperPrepareShow(QPlatformDialogHelper *)
QUrl::fromLocalFile(directory.absolutePath()) :
QUrl());
options->setInitiallySelectedNameFilter(q->selectedNameFilter());
- options->setInitiallySelectedFiles(userSelectedFiles());
+ if (options->initiallySelectedFiles().isEmpty())
+ options->setInitiallySelectedFiles(userSelectedFiles());
}
void QFileDialogPrivate::helperDone(QDialog::DialogCode code, QPlatformDialogHelper *)
@@ -755,9 +764,9 @@ void QFileDialogPrivate::emitFilesSelected(const QStringList &files)
emit q->fileSelected(files.first());
}
-bool QFileDialogPrivate::canBeNativeDialog()
+bool QFileDialogPrivate::canBeNativeDialog() const
{
- Q_Q(QFileDialog);
+ Q_Q(const QFileDialog);
if (nativeDialogInUse)
return true;
if (q->testAttribute(Qt::WA_DontShowOnScreen))
@@ -1045,10 +1054,13 @@ void QFileDialog::selectFile(const QString &filename)
return;
if (!d->usingWidgets()) {
- d->selectFile_sys(QUrl::fromLocalFile(filename));
- QList<QUrl> i;
- i << QUrl(filename);
- d->options->setInitiallySelectedFiles(i);
+ QUrl url = QUrl::fromLocalFile(filename);
+ if (QFileInfo(filename).isRelative()) {
+ QDir dir(d->options->initialDirectory().toLocalFile());
+ url = QUrl::fromLocalFile(dir.absoluteFilePath(filename));
+ }
+ d->selectFile_sys(url);
+ d->options->setInitiallySelectedFiles(QList<QUrl>() << url);
return;
}
@@ -1675,11 +1687,8 @@ void QFileDialog::setAcceptMode(QFileDialog::AcceptMode mode)
d->options->setAcceptMode(static_cast<QFileDialogOptions::AcceptMode>(mode));
// clear WA_DontShowOnScreen so that d->canBeNativeDialog() doesn't return false incorrectly
setAttribute(Qt::WA_DontShowOnScreen, false);
- if (!d->usingWidgets()) {
- // we need to recreate the native dialog when changing the AcceptMode
- d->deletePlatformHelper();
+ if (!d->usingWidgets())
return;
- }
QDialogButtonBox::StandardButton button = (mode == AcceptOpen ? QDialogButtonBox::Open : QDialogButtonBox::Save);
d->qFileDialogUi->buttonBox->setStandardButtons(button | QDialogButtonBox::Cancel);
d->qFileDialogUi->buttonBox->button(button)->setEnabled(false);
diff --git a/src/widgets/dialogs/qfiledialog_p.h b/src/widgets/dialogs/qfiledialog_p.h
index 36336bdbf6..faa721572c 100644
--- a/src/widgets/dialogs/qfiledialog_p.h
+++ b/src/widgets/dialogs/qfiledialog_p.h
@@ -251,7 +251,7 @@ public:
// setVisible_sys returns true if it ends up showing a native
// dialog. Returning false means that a non-native dialog must be
// used instead.
- bool canBeNativeDialog();
+ bool canBeNativeDialog() const;
inline bool usingWidgets() const;
void setDirectory_sys(const QUrl &directory);
diff --git a/src/widgets/dialogs/qmessagebox.cpp b/src/widgets/dialogs/qmessagebox.cpp
index 13aaca2f48..1b64b0ba67 100644
--- a/src/widgets/dialogs/qmessagebox.cpp
+++ b/src/widgets/dialogs/qmessagebox.cpp
@@ -193,7 +193,6 @@ public:
}
};
-
class QMessageBoxPrivate : public QDialogPrivate
{
Q_DECLARE_PUBLIC(QMessageBox)
@@ -204,11 +203,13 @@ public:
detailsText(0),
#endif
compatMode(false), autoAddOkButton(true),
- detectedEscapeButton(0), informativeLabel(0) { }
+ detectedEscapeButton(0), informativeLabel(0),
+ options(new QMessageDialogOptions) { }
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);
QAbstractButton *findButton(int button0, int button1, int button2, int flags);
void addOldButtons(int button0, int button1, int button2);
@@ -224,7 +225,6 @@ public:
#ifdef Q_OS_WINCE
void hideSpecial();
#endif
-
static int showOldMessageBox(QWidget *parent, QMessageBox::Icon icon,
const QString &title, const QString &text,
int button0, int button1, int button2);
@@ -262,6 +262,11 @@ public:
QPointer<QObject> receiverToDisconnectOnClose;
QByteArray memberToDisconnectOnClose;
QByteArray signalToDisconnectOnClose;
+ QSharedPointer<QMessageDialogOptions> options;
+private:
+ void initHelper(QPlatformDialogHelper *);
+ void helperPrepareShow(QPlatformDialogHelper *);
+ void helperDone(QDialog::DialogCode, QPlatformDialogHelper *);
};
void QMessageBoxPrivate::init(const QString &title, const QString &text)
@@ -519,6 +524,13 @@ void QMessageBoxPrivate::_q_buttonClicked(QAbstractButton *button)
}
}
+void QMessageBoxPrivate::_q_clicked(QMessageDialogOptions::StandardButton button, QMessageDialogOptions::ButtonRole role)
+{
+ Q_UNUSED(role);
+ Q_Q(QMessageBox);
+ q->done(button);
+}
+
/*!
\class QMessageBox
@@ -2682,6 +2694,54 @@ QPixmap QMessageBoxPrivate::standardIcon(QMessageBox::Icon icon, QMessageBox *mb
return QPixmap();
}
+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)));
+ static_cast<QPlatformMessageDialogHelper *>(h)->setOptions(options);
+}
+
+static QMessageDialogOptions::Icon helperIcon(QMessageBox::Icon i)
+{
+ switch (i) {
+ case QMessageBox::NoIcon:
+ return QMessageDialogOptions::NoIcon;
+ case QMessageBox::Information:
+ return QMessageDialogOptions::Information;
+ case QMessageBox::Warning:
+ return QMessageDialogOptions::Warning;
+ case QMessageBox::Critical:
+ return QMessageDialogOptions::Critical;
+ case QMessageBox::Question:
+ return QMessageDialogOptions::Question;
+ }
+ return QMessageDialogOptions::NoIcon;
+}
+
+static QMessageDialogOptions::StandardButtons helperStandardButtons(QMessageBox * q)
+{
+ QMessageDialogOptions::StandardButtons buttons(int(q->standardButtons()));
+ return buttons;
+}
+
+void QMessageBoxPrivate::helperPrepareShow(QPlatformDialogHelper *)
+{
+ Q_Q(QMessageBox);
+ options->setWindowTitle(q->windowTitle());
+ options->setText(q->text());
+ options->setInformativeText(q->informativeText());
+ options->setDetailedText(q->detailedText());
+ options->setIcon(helperIcon(q->icon()));
+ options->setStandardButtons(helperStandardButtons(q));
+}
+
+void QMessageBoxPrivate::helperDone(QDialog::DialogCode code, QPlatformDialogHelper *)
+{
+ Q_Q(QMessageBox);
+ clickedButton = q->button(QMessageBox::StandardButton(code));
+}
+
/*!
\obsolete
diff --git a/src/widgets/dialogs/qmessagebox.h b/src/widgets/dialogs/qmessagebox.h
index 58be13426c..c5598a8f1d 100644
--- a/src/widgets/dialogs/qmessagebox.h
+++ b/src/widgets/dialogs/qmessagebox.h
@@ -309,6 +309,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_DISABLE_COPY(QMessageBox)
Q_DECLARE_PRIVATE(QMessageBox)
diff --git a/src/widgets/dialogs/qwizard.cpp b/src/widgets/dialogs/qwizard.cpp
index 02ad5a3be5..a667f299e8 100644
--- a/src/widgets/dialogs/qwizard.cpp
+++ b/src/widgets/dialogs/qwizard.cpp
@@ -1345,6 +1345,33 @@ void QWizardPrivate::updateCurrentPage()
updateButtonTexts();
}
+static QString object_name_for_button(QWizard::WizardButton which)
+{
+ switch (which) {
+ case QWizard::CommitButton:
+ return QLatin1String("qt_wizard_") + QLatin1String("commit");
+ case QWizard::FinishButton:
+ return QLatin1String("qt_wizard_") + QLatin1String("finish");
+ case QWizard::CancelButton:
+ return QLatin1String("qt_wizard_") + QLatin1String("cancel");
+ case QWizard::BackButton:
+ case QWizard::NextButton:
+ case QWizard::HelpButton:
+ case QWizard::CustomButton1:
+ case QWizard::CustomButton2:
+ case QWizard::CustomButton3:
+ // Make navigation buttons detectable as passive interactor in designer
+ return QLatin1String("__qt__passive_wizardbutton") + QString::number(which);
+ case QWizard::Stretch:
+ case QWizard::NoButton:
+ //case QWizard::NStandardButtons:
+ //case QWizard::NButtons:
+ ;
+ }
+ Q_UNREACHABLE();
+ return QString();
+}
+
bool QWizardPrivate::ensureButton(QWizard::WizardButton which) const
{
Q_Q(const QWizard);
@@ -1356,19 +1383,7 @@ bool QWizardPrivate::ensureButton(QWizard::WizardButton which) const
QStyle *style = q->style();
if (style != QApplication::style()) // Propagate style
pushButton->setStyle(style);
- // Make navigation buttons detectable as passive interactor in designer
- switch (which) {
- case QWizard::CommitButton:
- case QWizard::FinishButton:
- case QWizard::CancelButton:
- break;
- default: {
- QString objectName = QLatin1String("__qt__passive_wizardbutton");
- objectName += QString::number(which);
- pushButton->setObjectName(objectName);
- }
- break;
- }
+ pushButton->setObjectName(object_name_for_button(which));
#ifdef Q_OS_MACX
pushButton->setAutoDefault(false);
#endif
diff --git a/src/widgets/doc/qtwidgets.qdocconf b/src/widgets/doc/qtwidgets.qdocconf
index d3c7825bc0..b742856892 100644
--- a/src/widgets/doc/qtwidgets.qdocconf
+++ b/src/widgets/doc/qtwidgets.qdocconf
@@ -2,7 +2,7 @@ include($QT_INSTALL_DOCS/global/qt-module-defaults.qdocconf)
project = QtWidgets
description = Qt Widgets Reference Documentation
-url = http://qt-project.org/doc/qt-$QT_VER/qtwidgets
+url = http://qt-project.org/doc/qt-$QT_VER
version = $QT_VERSION
examplesinstallpath = widgets
diff --git a/src/widgets/doc/src/widgets-and-layouts/layout.qdoc b/src/widgets/doc/src/widgets-and-layouts/layout.qdoc
index f74da2fa0a..99d512b507 100644
--- a/src/widgets/doc/src/widgets-and-layouts/layout.qdoc
+++ b/src/widgets/doc/src/widgets-and-layouts/layout.qdoc
@@ -32,8 +32,8 @@
\brief A tour of the standard layout managers and an introduction to custom
layouts.
- \previouspage Widgets and Layouts
- \contentspage Widgets and Layouts
+ \previouspage Qt Widgets
+ \contentspage Qt Widgets
\nextpage {Styles and Style Aware Widgets}{Styles}
\ingroup frameworks-technologies
diff --git a/src/widgets/doc/src/widgets-tutorial.qdoc b/src/widgets/doc/src/widgets-tutorial.qdoc
index 985a430cba..d4cf063231 100644
--- a/src/widgets/doc/src/widgets-tutorial.qdoc
+++ b/src/widgets/doc/src/widgets-tutorial.qdoc
@@ -89,7 +89,7 @@
\section1 Real world widget examples
- In these \l{Widget examples} {more advanced examples}, the code
+ In these \l{Qt Widgets Examples} {more advanced examples}, the code
that creates the widgets and layouts is stored in other files. For
example, the GUI for a main window may be created in the
constructor of a QMainWindow subclass.
diff --git a/src/widgets/graphicsview/qgraphicsitem.cpp b/src/widgets/graphicsview/qgraphicsitem.cpp
index 7cab132a2e..a4adb3d20b 100644
--- a/src/widgets/graphicsview/qgraphicsitem.cpp
+++ b/src/widgets/graphicsview/qgraphicsitem.cpp
@@ -10307,7 +10307,9 @@ void QGraphicsTextItem::hoverLeaveEvent(QGraphicsSceneHoverEvent *event)
QVariant QGraphicsTextItem::inputMethodQuery(Qt::InputMethodQuery query) const
{
QVariant v;
- if (dd->control)
+ if (query == Qt::ImHints)
+ v = int(inputMethodHints());
+ else if (dd->control)
v = dd->control->inputMethodQuery(query);
if (v.type() == QVariant::RectF)
v = v.toRectF().translated(-dd->controlOffset());
diff --git a/src/widgets/graphicsview/qgraphicsscene.cpp b/src/widgets/graphicsview/qgraphicsscene.cpp
index ad7a82518e..41d4fc925a 100644
--- a/src/widgets/graphicsview/qgraphicsscene.cpp
+++ b/src/widgets/graphicsview/qgraphicsscene.cpp
@@ -4147,8 +4147,9 @@ void QGraphicsScene::wheelEvent(QGraphicsSceneWheelEvent *wheelEvent)
wheelEvent->widget()));
wheelEvent->accept();
bool isPanel = item->isPanel();
- d->sendEvent(item, wheelEvent);
- if (isPanel || wheelEvent->isAccepted())
+ bool ret = d->sendEvent(item, wheelEvent);
+
+ if (ret && (isPanel || wheelEvent->isAccepted()))
break;
}
}
diff --git a/src/widgets/graphicsview/qgraphicswidget_p.cpp b/src/widgets/graphicsview/qgraphicswidget_p.cpp
index 14cd7007ba..e1dd23f177 100644
--- a/src/widgets/graphicsview/qgraphicswidget_p.cpp
+++ b/src/widgets/graphicsview/qgraphicswidget_p.cpp
@@ -90,11 +90,6 @@ qreal QGraphicsWidgetPrivate::titleBarHeight(const QStyleOptionTitleBar &options
{
Q_Q(const QGraphicsWidget);
int height = q->style()->pixelMetric(QStyle::PM_TitleBarHeight, &options);
-#if defined(Q_WS_MAC) && !defined(QT_NO_STYLE_MAC)
- if (qobject_cast<QMacStyle*>(q->style())) {
- height -=4;
- }
-#endif
return (qreal)height;
}
diff --git a/src/widgets/itemviews/qabstractitemview.cpp b/src/widgets/itemviews/qabstractitemview.cpp
index 726c2704c4..7edad74f54 100644
--- a/src/widgets/itemviews/qabstractitemview.cpp
+++ b/src/widgets/itemviews/qabstractitemview.cpp
@@ -1042,7 +1042,7 @@ QAbstractItemView::SelectionBehavior QAbstractItemView::selectionBehavior() cons
Sets the current item to be the item at \a index.
Unless the current selection mode is
- \l{QAbstractItemView::}{NoSelection}, the item is also be selected.
+ \l{QAbstractItemView::}{NoSelection}, the item is also selected.
Note that this function also updates the starting position for any
new selections the user performs.
@@ -1391,6 +1391,15 @@ bool QAbstractItemView::showDropIndicator() const
}
/*!
+ \since 5.2
+ \reimp
+*/
+QSize QAbstractItemView::viewportSizeHint() const
+{
+ return QAbstractScrollArea::viewportSizeHint();
+}
+
+/*!
\property QAbstractItemView::dragEnabled
\brief whether the view supports dragging of its own items
diff --git a/src/widgets/itemviews/qabstractitemview.h b/src/widgets/itemviews/qabstractitemview.h
index 96428515ae..4f9cd7b1c6 100644
--- a/src/widgets/itemviews/qabstractitemview.h
+++ b/src/widgets/itemviews/qabstractitemview.h
@@ -346,6 +346,8 @@ protected:
DropIndicatorPosition dropIndicatorPosition() const;
#endif
+ QSize viewportSizeHint() const Q_DECL_OVERRIDE;
+
private:
Q_DECLARE_PRIVATE(QAbstractItemView)
Q_DISABLE_COPY(QAbstractItemView)
diff --git a/src/widgets/itemviews/qheaderview.cpp b/src/widgets/itemviews/qheaderview.cpp
index 1131ef030e..75a513fb67 100644
--- a/src/widgets/itemviews/qheaderview.cpp
+++ b/src/widgets/itemviews/qheaderview.cpp
@@ -1337,18 +1337,13 @@ QHeaderView::ResizeMode QHeaderView::sectionResizeMode(int logicalIndex) const
and QTreeView::sizeHintForColumn(). Reimplementing these functions can make this
function not having an effect.
- If \a resizeSectionsNow is set to true (default) it will do adjustment of sections by calling
- resizeSections(). (regardless if the precision was changed).
-
\sa resizeContentsPrecision(), setSectionResizeMode(), resizeSections(), QTableView::sizeHintForColumn(), QTableView::sizeHintForRow(), QTreeView::sizeHintForColumn()
*/
-void QHeaderView::setResizeContentsPrecision(int precision, bool resizeSectionsNow)
+void QHeaderView::setResizeContentsPrecision(int precision)
{
Q_D(QHeaderView);
d->resizeContentsPrecision = precision;
- if (resizeSectionsNow)
- resizeSections();
}
/*!
@@ -1604,7 +1599,7 @@ int QHeaderView::minimumSectionSize() const
void QHeaderView::setMinimumSectionSize(int size)
{
Q_D(QHeaderView);
- if (size < 0 || size > maxSizeSection)
+ if (size < -1 || size > maxSizeSection)
return;
d->minimumSectionSize = size;
if (d->minimumSectionSize > maximumSectionSize())
diff --git a/src/widgets/itemviews/qheaderview.h b/src/widgets/itemviews/qheaderview.h
index b3ed666aa6..bfe36e9b19 100644
--- a/src/widgets/itemviews/qheaderview.h
+++ b/src/widgets/itemviews/qheaderview.h
@@ -135,7 +135,7 @@ public:
void setSectionResizeMode(ResizeMode mode);
void setSectionResizeMode(int logicalIndex, ResizeMode mode);
- void setResizeContentsPrecision(int precision, bool resizeNow = true);
+ void setResizeContentsPrecision(int precision);
int resizeContentsPrecision() const;
#if QT_DEPRECATED_SINCE(5, 0)
diff --git a/src/widgets/itemviews/qlistview.cpp b/src/widgets/itemviews/qlistview.cpp
index 616a832b88..0cca52daa2 100644
--- a/src/widgets/itemviews/qlistview.cpp
+++ b/src/widgets/itemviews/qlistview.cpp
@@ -3200,6 +3200,16 @@ int QListView::visualIndex(const QModelIndex &index) const
return visualIndex;
}
+
+/*!
+ \since 5.2
+ \reimp
+*/
+QSize QListView::viewportSizeHint() const
+{
+ return QAbstractItemView::viewportSizeHint();
+}
+
QT_END_NAMESPACE
#endif // QT_NO_LISTVIEW
diff --git a/src/widgets/itemviews/qlistview.h b/src/widgets/itemviews/qlistview.h
index e4ae2d03fd..a973dfb221 100644
--- a/src/widgets/itemviews/qlistview.h
+++ b/src/widgets/itemviews/qlistview.h
@@ -180,6 +180,8 @@ protected:
void selectionChanged(const QItemSelection &selected, const QItemSelection &deselected);
void currentChanged(const QModelIndex &current, const QModelIndex &previous);
+ QSize viewportSizeHint() const Q_DECL_OVERRIDE;
+
private:
int visualIndex(const QModelIndex &index) const;
diff --git a/src/widgets/itemviews/qlistwidget.cpp b/src/widgets/itemviews/qlistwidget.cpp
index aa1dbf1de3..5040192f31 100644
--- a/src/widgets/itemviews/qlistwidget.cpp
+++ b/src/widgets/itemviews/qlistwidget.cpp
@@ -1456,7 +1456,7 @@ QListWidgetItem *QListWidget::currentItem() const
Sets the current item to \a item.
Unless the selection mode is \l{QAbstractItemView::}{NoSelection},
- the item is also be selected.
+ the item is also selected.
*/
void QListWidget::setCurrentItem(QListWidgetItem *item)
{
diff --git a/src/widgets/itemviews/qtableview.h b/src/widgets/itemviews/qtableview.h
index db956480d6..387d24c608 100644
--- a/src/widgets/itemviews/qtableview.h
+++ b/src/widgets/itemviews/qtableview.h
@@ -118,8 +118,6 @@ public:
void sortByColumn(int column, Qt::SortOrder order);
- QSize viewportSizeHint() const;
-
public Q_SLOTS:
void selectRow(int row);
void selectColumn(int column);
@@ -161,6 +159,8 @@ protected:
void updateGeometries();
+ QSize viewportSizeHint() const Q_DECL_OVERRIDE;
+
int sizeHintForRow(int row) const;
int sizeHintForColumn(int column) const;
diff --git a/src/widgets/itemviews/qtablewidget.cpp b/src/widgets/itemviews/qtablewidget.cpp
index 43b6b62cc1..71034f6165 100644
--- a/src/widgets/itemviews/qtablewidget.cpp
+++ b/src/widgets/itemviews/qtablewidget.cpp
@@ -2125,7 +2125,7 @@ QTableWidgetItem *QTableWidget::currentItem() const
Sets the current item to \a item.
Unless the selection mode is \l{QAbstractItemView::}{NoSelection},
- the item is also be selected.
+ the item is also selected.
\sa currentItem(), setCurrentCell()
*/
diff --git a/src/widgets/itemviews/qtreeview.cpp b/src/widgets/itemviews/qtreeview.cpp
index 792b75ac69..4d0eb5c3ad 100644
--- a/src/widgets/itemviews/qtreeview.cpp
+++ b/src/widgets/itemviews/qtreeview.cpp
@@ -2858,6 +2858,21 @@ int QTreeView::sizeHintForColumn(int column) const
int offset = 0;
int start = d->firstVisibleItem(&offset);
int end = d->lastVisibleItem(start, offset);
+ if (start < 0 || end < 0 || end == viewItems.size() - 1) {
+ end = viewItems.size() - 1;
+ if (maximumProcessRows < 0) {
+ start = 0;
+ } else if (maximumProcessRows == 0) {
+ start = qMax(0, end - 1);
+ int remainingHeight = viewport()->height();
+ while (start > 0 && remainingHeight > 0) {
+ remainingHeight -= d->itemHeight(start);
+ --start;
+ }
+ } else {
+ start = qMax(0, end - maximumProcessRows);
+ }
+ }
int rowsProcessed = 0;
@@ -3606,8 +3621,11 @@ int QTreeViewPrivate::firstVisibleItem(int *offset) const
int QTreeViewPrivate::lastVisibleItem(int firstVisual, int offset) const
{
- if (firstVisual < 0 || offset < 0)
+ if (firstVisual < 0 || offset < 0) {
firstVisual = firstVisibleItem(&offset);
+ if (firstVisual < 0)
+ return -1;
+ }
int y = - offset;
int value = viewport->height();
@@ -3888,6 +3906,14 @@ void QTreeViewPrivate::_q_sortIndicatorChanged(int column, Qt::SortOrder order)
model->sort(column, order);
}
+int QTreeViewPrivate::accessibleTree2Index(const QModelIndex &index) const
+{
+ Q_Q(const QTreeView);
+
+ // Note that this will include the header, even if its hidden.
+ return (q->visualIndex(index) + (q->header() ? 1 : 0)) * index.model()->columnCount() + index.column();
+}
+
/*!
\reimp
*/
@@ -3911,8 +3937,10 @@ void QTreeView::currentChanged(const QModelIndex &current, const QModelIndex &pr
}
#ifndef QT_NO_ACCESSIBILITY
if (QAccessible::isActive() && current.isValid()) {
+ Q_D(QTreeView);
+
QAccessibleEvent event(this, QAccessible::Focus);
- event.setChild(accessibleTree2Index(current));
+ event.setChild(d->accessibleTree2Index(current));
QAccessible::updateAccessibility(&event);
}
#endif
@@ -3927,10 +3955,12 @@ void QTreeView::selectionChanged(const QItemSelection &selected,
QAbstractItemView::selectionChanged(selected, deselected);
#ifndef QT_NO_ACCESSIBILITY
if (QAccessible::isActive()) {
+ Q_D(QTreeView);
+
// ### does not work properly for selection ranges.
QModelIndex sel = selected.indexes().value(0);
if (sel.isValid()) {
- int entry = accessibleTree2Index(sel);
+ int entry = d->accessibleTree2Index(sel);
Q_ASSERT(entry >= 0);
QAccessibleEvent event(this, QAccessible::Selection);
event.setChild(entry);
@@ -3938,7 +3968,7 @@ void QTreeView::selectionChanged(const QItemSelection &selected,
}
QModelIndex desel = deselected.indexes().value(0);
if (desel.isValid()) {
- int entry = accessibleTree2Index(desel);
+ int entry = d->accessibleTree2Index(desel);
Q_ASSERT(entry >= 0);
QAccessibleEvent event(this, QAccessible::SelectionRemove);
event.setChild(entry);
@@ -3955,13 +3985,6 @@ int QTreeView::visualIndex(const QModelIndex &index) const
return d->viewIndex(index);
}
-int QTreeView::accessibleTree2Index(const QModelIndex &index) const
-{
- // Note that this will include the header, even if its hidden.
- return (visualIndex(index) + (header() ? 1 : 0)) * index.model()->columnCount() + index.column();
-}
-
-
QT_END_NAMESPACE
#include "moc_qtreeview.cpp"
diff --git a/src/widgets/itemviews/qtreeview.h b/src/widgets/itemviews/qtreeview.h
index a29e9b64b0..429b9d3add 100644
--- a/src/widgets/itemviews/qtreeview.h
+++ b/src/widgets/itemviews/qtreeview.h
@@ -147,8 +147,6 @@ public:
void dataChanged(const QModelIndex &topLeft, const QModelIndex &bottomRight, const QVector<int> &roles = QVector<int>());
void selectAll();
- QSize viewportSizeHint() const;
-
Q_SIGNALS:
void expanded(const QModelIndex &index);
void collapsed(const QModelIndex &index);
@@ -208,6 +206,8 @@ protected:
void updateGeometries();
+ QSize viewportSizeHint() const Q_DECL_OVERRIDE;
+
int sizeHintForColumn(int column) const;
int indexRowSizeHint(const QModelIndex &index) const;
int rowHeight(const QModelIndex &index) const;
@@ -224,7 +224,6 @@ private:
friend class QAccessibleTree;
friend class QAccessibleTableCell;
int visualIndex(const QModelIndex &index) const;
- int accessibleTree2Index(const QModelIndex &index) const;
Q_DECLARE_PRIVATE(QTreeView)
Q_DISABLE_COPY(QTreeView)
diff --git a/src/widgets/itemviews/qtreeview_p.h b/src/widgets/itemviews/qtreeview_p.h
index 89de435606..5d6333e856 100644
--- a/src/widgets/itemviews/qtreeview_p.h
+++ b/src/widgets/itemviews/qtreeview_p.h
@@ -239,6 +239,8 @@ public:
return (viewIndex(index) + (header ? 1 : 0)) * model->columnCount()+index.column();
}
+ int accessibleTree2Index(const QModelIndex &index) const;
+
// used for spanning rows
QVector<QPersistentModelIndex> spanningIndexes;
diff --git a/src/widgets/kernel/qapplication.cpp b/src/widgets/kernel/qapplication.cpp
index 210cb29120..57a2063b78 100644
--- a/src/widgets/kernel/qapplication.cpp
+++ b/src/widgets/kernel/qapplication.cpp
@@ -111,13 +111,10 @@ extern bool qt_wince_is_pocket_pc(); //qguifunctions_wince.cpp
static void initResources()
{
#if defined(Q_OS_WINCE)
- Q_INIT_RESOURCE_EXTERN(qstyle_wince)
Q_INIT_RESOURCE(qstyle_wince);
#else
- Q_INIT_RESOURCE_EXTERN(qstyle)
Q_INIT_RESOURCE(qstyle);
#endif
- Q_INIT_RESOURCE_EXTERN(qmessagebox)
Q_INIT_RESOURCE(qmessagebox);
}
@@ -3762,6 +3759,16 @@ void QApplicationPrivate::giveFocusAccordingToFocusPolicy(QWidget *widget, QEven
}
if (focusWidget->isWindow())
break;
+
+ // find out whether this widget (or its proxy) already has focus
+ QWidget *f = focusWidget;
+ if (focusWidget->d_func()->extra && focusWidget->d_func()->extra->focus_proxy)
+ f = focusWidget->d_func()->extra->focus_proxy;
+ // if it has, stop here.
+ // otherwise a click on the focused widget would remove its focus if ClickFocus isn't set
+ if (f->hasFocus())
+ break;
+
localPos += focusWidget->pos();
focusWidget = focusWidget->parentWidget();
}
diff --git a/src/widgets/kernel/qformlayout.cpp b/src/widgets/kernel/qformlayout.cpp
index e1376c754f..c1d3e95e7a 100644
--- a/src/widgets/kernel/qformlayout.cpp
+++ b/src/widgets/kernel/qformlayout.cpp
@@ -641,7 +641,7 @@ static inline int spacingHelper(QWidget* parent, QStyle *style, int userVSpacing
spacing = qMax(spacing, prevItem2->geometry().top() - wid->geometry().top() );
}
}
- return spacing;
+ return qMax(spacing, 0);
}
static inline void initLayoutStruct(QLayoutStruct& sl, QFormLayoutItem* item)
diff --git a/src/widgets/kernel/qlayout.cpp b/src/widgets/kernel/qlayout.cpp
index cd2891d829..eb21a580b1 100644
--- a/src/widgets/kernel/qlayout.cpp
+++ b/src/widgets/kernel/qlayout.cpp
@@ -1112,18 +1112,26 @@ bool QLayout::activate()
\since 5.2
Searches for widget \a from and replaces it with widget \a to if found.
- Returns the layout item that contains the widget \a from on success. Otherwise \c 0 is returned.
- If \a recursive is \c true, sub-layouts are searched for doing the replacement. Notice that the returned item therefore might not belong to this layout, but to a sub-layout.
+ Returns the layout item that contains the widget \a from on success.
+ Otherwise \c 0 is returned. If \a options contains \c Qt::FindChildrenRecursively
+ (the default), sub-layouts are searched for doing the replacement.
+ Any other flag in \a options is ignored.
- The returned layout item is no longer owned by the layout and should be either deleted or inserted to another layout. The widget \a from is no longer managed by the layout and may need to be deleted or hidden. The parent of widget \a from is left unchanged.
+ Notice that the returned item therefore might not belong to this layout,
+ but to a sub-layout.
- This function works for the built-in Qt layouts, but might not work for custom layouts.
+ The returned layout item is no longer owned by the layout and should be
+ either deleted or inserted to another layout. The widget \a from is no
+ longer managed by the layout and may need to be deleted or hidden. The
+ parent of widget \a from is left unchanged.
+
+ This function works for the built-in Qt layouts, but might not work for
+ custom layouts.
\sa indexOf()
*/
-//### Qt 6 make this function virtual
-QLayoutItem* QLayout::replaceWidget(QWidget *from, QWidget *to, bool recursive)
+QLayoutItem *QLayout::replaceWidget(QWidget *from, QWidget *to, Qt::FindChildOptions options)
{
Q_D(QLayout);
if (!from || !to)
@@ -1133,12 +1141,16 @@ QLayoutItem* QLayout::replaceWidget(QWidget *from, QWidget *to, bool recursive)
QLayoutItem *item = 0;
for (int u = 0; u < count(); ++u) {
item = itemAt(u);
+ if (!item)
+ continue;
+
if (item->widget() == from) {
index = u;
break;
}
- if (item && item->layout() && recursive) {
- QLayoutItem *r = item->layout()->replaceWidget(from, to, true);
+
+ if (item->layout() && (options & Qt::FindChildrenRecursively)) {
+ QLayoutItem *r = item->layout()->replaceWidget(from, to, options);
if (r)
return r;
}
diff --git a/src/widgets/kernel/qlayout.h b/src/widgets/kernel/qlayout.h
index ca5f6d42ea..27d9d34b9c 100644
--- a/src/widgets/kernel/qlayout.h
+++ b/src/widgets/kernel/qlayout.h
@@ -130,7 +130,9 @@ public:
virtual int count() const = 0;
bool isEmpty() const;
QSizePolicy::ControlTypes controlTypes() const;
- QLayoutItem* replaceWidget(QWidget *from, QWidget *to, bool recursive = true);
+
+ // ### Qt 6 make this function virtual
+ QLayoutItem *replaceWidget(QWidget *from, QWidget *to, Qt::FindChildOptions options = Qt::FindChildrenRecursively);
int totalHeightForWidth(int w) const;
QSize totalMinimumSize() const;
diff --git a/src/widgets/kernel/qwidget.cpp b/src/widgets/kernel/qwidget.cpp
index 55459ac1ac..0d8e20ca0c 100644
--- a/src/widgets/kernel/qwidget.cpp
+++ b/src/widgets/kernel/qwidget.cpp
@@ -289,7 +289,7 @@ QWidgetPrivate::QWidgetPrivate(int version)
#endif
{
if (!qApp) {
- qFatal("QWidget: Must construct a QApplication before a QPaintDevice");
+ qFatal("QWidget: Must construct a QApplication before a QWidget");
return;
}
@@ -6999,21 +6999,23 @@ void QWidget::setUpdatesEnabled(bool enable)
}
/*!
- Shows the widget and its child widgets. This function is
- equivalent to setVisible(true) in the normal case, and equivalent
- to showFullScreen() if the QStyleHints::showIsFullScreen() hint
- is true and the window is not a popup.
+ Shows the widget and its child widgets.
- \sa raise(), showEvent(), hide(), setVisible(), showMinimized(), showMaximized(),
- showNormal(), isVisible(), windowFlags()
+ This is equivalent to calling showFullScreen(), showMaximized(), or setVisible(true),
+ depending on the platform's default behavior for the window flags.
+
+ \sa raise(), showEvent(), hide(), setVisible(), showMinimized(), showMaximized(),
+ showNormal(), isVisible(), windowFlags(), flags()
*/
void QWidget::show()
{
- bool isPopup = data->window_flags & Qt::Popup & ~Qt::Window;
- if (isWindow() && !isPopup && qApp->styleHints()->showIsFullScreen())
+ Qt::WindowState defaultState = QGuiApplicationPrivate::platformIntegration()->defaultWindowState(data->window_flags);
+ if (defaultState == Qt::WindowFullScreen)
showFullScreen();
+ else if (defaultState == Qt::WindowMaximized)
+ showMaximized();
else
- setVisible(true);
+ setVisible(true); // FIXME: Why not showNormal(), like QWindow::show()?
}
/*! \internal
diff --git a/src/widgets/kernel/qwidget.h b/src/widgets/kernel/qwidget.h
index a9eeaa5470..159011b824 100644
--- a/src/widgets/kernel/qwidget.h
+++ b/src/widgets/kernel/qwidget.h
@@ -733,6 +733,7 @@ private:
Q_DECLARE_OPERATORS_FOR_FLAGS(QWidget::RenderFlags)
+#ifndef Q_QDOC
template <> inline QWidget *qobject_cast<QWidget*>(QObject *o)
{
if (!o || !o->isWidgetType()) return 0;
@@ -743,6 +744,7 @@ template <> inline const QWidget *qobject_cast<const QWidget*>(const QObject *o)
if (!o || !o->isWidgetType()) return 0;
return static_cast<const QWidget*>(o);
}
+#endif // !Q_QDOC
inline QWidget *QWidget::childAt(int ax, int ay) const
{ return childAt(QPoint(ax, ay)); }
diff --git a/src/widgets/kernel/qwidget_qpa.cpp b/src/widgets/kernel/qwidget_qpa.cpp
index ae8a0b25b9..93234f3958 100644
--- a/src/widgets/kernel/qwidget_qpa.cpp
+++ b/src/widgets/kernel/qwidget_qpa.cpp
@@ -53,6 +53,7 @@
#include <qpa/qplatformintegration.h>
#include "QtGui/private/qwindow_p.h"
#include "QtGui/private/qguiapplication_p.h"
+#include <private/qwindowcontainer_p.h>
#include <qpa/qplatformcursor.h>
#include <QtGui/QGuiApplication>
@@ -267,8 +268,11 @@ void QWidgetPrivate::setParent_sys(QWidget *newparent, Qt::WindowFlags f)
bool explicitlyHidden = q->testAttribute(Qt::WA_WState_Hidden) && q->testAttribute(Qt::WA_WState_ExplicitShowHide);
// Reparenting toplevel to child
- if (wasCreated && !(f & Qt::Window) && (oldFlags & Qt::Window) && !q->testAttribute(Qt::WA_NativeWindow))
+ if (wasCreated && !(f & Qt::Window) && (oldFlags & Qt::Window) && !q->testAttribute(Qt::WA_NativeWindow)) {
+ if (extra && extra->hasWindowContainer)
+ QWindowContainer::toplevelAboutToBeDestroyed(q);
q->destroy();
+ }
adjustFlags(f, q);
data.window_flags = f;
diff --git a/src/widgets/kernel/qwidgetbackingstore_p.h b/src/widgets/kernel/qwidgetbackingstore_p.h
index 39583c8caa..b6c3e13cb0 100644
--- a/src/widgets/kernel/qwidgetbackingstore_p.h
+++ b/src/widgets/kernel/qwidgetbackingstore_p.h
@@ -240,7 +240,13 @@ private:
}
inline bool hasStaticContents() const
- { return !staticWidgets.isEmpty() && false; }
+ {
+#if defined(Q_OS_WIN)
+ return !staticWidgets.isEmpty();
+#else
+ return !staticWidgets.isEmpty() && false;
+#endif
+ }
friend QRegion qt_dirtyRegion(QWidget *);
friend class QWidgetPrivate;
diff --git a/src/widgets/kernel/qwidgetwindow.cpp b/src/widgets/kernel/qwidgetwindow.cpp
index 51a0eb7d72..2e96247873 100644
--- a/src/widgets/kernel/qwidgetwindow.cpp
+++ b/src/widgets/kernel/qwidgetwindow.cpp
@@ -76,6 +76,13 @@ public:
}
return w;
}
+
+ void clearFocusObject()
+ {
+ if (QApplicationPrivate::focus_widget)
+ QApplicationPrivate::focus_widget->clearFocus();
+ }
+
};
QWidgetWindow::QWidgetWindow(QWidget *widget)
@@ -244,7 +251,9 @@ bool QWidgetWindow::event(QEvent *event)
case QEvent::Show:
case QEvent::Hide:
return QWindow::event(event);
-
+ case QEvent::WindowBlocked:
+ qt_button_down = 0;
+ break;
default:
break;
}
diff --git a/src/widgets/kernel/qwindowcontainer.cpp b/src/widgets/kernel/qwindowcontainer.cpp
index 6914f64f8e..399f089e0f 100644
--- a/src/widgets/kernel/qwindowcontainer.cpp
+++ b/src/widgets/kernel/qwindowcontainer.cpp
@@ -222,6 +222,11 @@ void QWindowContainer::focusWindowChanged(QWindow *focusWindow)
{
Q_D(QWindowContainer);
d->oldFocusWindow = focusWindow;
+ if (focusWindow == d->window) {
+ QWidget *widget = QApplication::focusWidget();
+ if (widget)
+ widget->clearFocus();
+ }
}
/*!
@@ -300,15 +305,28 @@ static void qwindowcontainer_traverse(QWidget *parent, qwindowcontainer_traverse
}
}
+void QWindowContainer::toplevelAboutToBeDestroyed(QWidget *parent)
+{
+ if (QWindowContainerPrivate *d = QWindowContainerPrivate::get(parent)) {
+ d->window->setParent(&d->fakeParent);
+ }
+ qwindowcontainer_traverse(parent, toplevelAboutToBeDestroyed);
+}
+
void QWindowContainer::parentWasChanged(QWidget *parent)
{
if (QWindowContainerPrivate *d = QWindowContainerPrivate::get(parent)) {
if (d->window->parent()) {
d->updateUsesNativeWidgets();
d->markParentChain();
- d->window->setParent(d->usesNativeWidgets
- ? parent->windowHandle()
- : parent->window()->windowHandle());
+ QWidget *toplevel = d->usesNativeWidgets ? parent : parent->window();
+ if (!toplevel->windowHandle()) {
+ QWidgetPrivate *tld = static_cast<QWidgetPrivate *>(QWidgetPrivate::get(toplevel));
+ tld->createTLExtra();
+ tld->createTLSysExtra();
+ Q_ASSERT(toplevel->windowHandle());
+ }
+ d->window->setParent(toplevel->windowHandle());
d->updateGeometry();
}
}
diff --git a/src/widgets/kernel/qwindowcontainer_p.h b/src/widgets/kernel/qwindowcontainer_p.h
index e2446bef42..a21f9bd35a 100644
--- a/src/widgets/kernel/qwindowcontainer_p.h
+++ b/src/widgets/kernel/qwindowcontainer_p.h
@@ -57,6 +57,7 @@ public:
explicit QWindowContainer(QWindow *embeddedWindow, QWidget *parent = 0, Qt::WindowFlags f = 0);
~QWindowContainer();
+ static void toplevelAboutToBeDestroyed(QWidget *parent);
static void parentWasChanged(QWidget *parent);
static void parentWasMoved(QWidget *parent);
static void parentWasRaised(QWidget *parent);
diff --git a/src/widgets/kernel/win.pri b/src/widgets/kernel/win.pri
index 18bd692476..76bb709e2b 100644
--- a/src/widgets/kernel/win.pri
+++ b/src/widgets/kernel/win.pri
@@ -3,5 +3,5 @@
INCLUDEPATH += ../3rdparty/wintab
!wince*:!winrt {
- LIBS *= -lshell32
+ LIBS_PRIVATE *= -lshell32
}
diff --git a/src/widgets/styles/qandroidstyle.cpp b/src/widgets/styles/qandroidstyle.cpp
index afd6c3024c..ceb95aa125 100644
--- a/src/widgets/styles/qandroidstyle.cpp
+++ b/src/widgets/styles/qandroidstyle.cpp
@@ -515,8 +515,15 @@ void QAndroidStyle::drawPrimitive(PrimitiveElement pe,
AndroidControlsHash::const_iterator it = itemType != QC_UnknownType
? m_androidControlsHash.find(itemType)
: m_androidControlsHash.end();
- if (it != m_androidControlsHash.end())
- it.value()->drawControl(opt, p, w);
+ if (it != m_androidControlsHash.end()) {
+ if (itemType != QC_EditText)
+ it.value()->drawControl(opt, p, w);
+ else {
+ QStyleOption copy(*opt);
+ copy.state &= ~QStyle::State_Sunken;
+ it.value()->drawControl(&copy, p, w);
+ }
+ }
else
QFusionStyle::drawPrimitive(pe, opt, p, w);
}
@@ -696,7 +703,10 @@ int QAndroidStyle::styleHint(QStyle::StyleHint hint, const QStyleOption *option,
{
switch (hint) {
case SH_Slider_AbsoluteSetButtons:
- return 1;
+ return Qt::LeftButton;
+
+ case SH_Slider_PageSetButtons:
+ return 0;
case SH_RequestSoftwareInputPanel:
return RSIP_OnMouseClick;
@@ -1776,9 +1786,9 @@ QRect QAndroidStyle::AndroidSeekBarControl::subControlRect(const QStyleOptionCom
drawable = static_cast<const QAndroidStyle::AndroidStateDrawable *>(m_seekBarThumb)->bestAndroidStateMatch(option);
QRect r(option->rect);
- double factor = double(styleOption->sliderPosition/(styleOption->maximum-styleOption->minimum));
- int pos=(double(option->rect.width()*factor - drawable->size().width()) / 2);
- r.setX(r.x()+pos);
+ double factor = double(styleOption->sliderPosition) / (styleOption->maximum - styleOption->minimum);
+ int pos = option->rect.width() * factor - double(drawable->size().width() / 2);
+ r.setX(r.x() + pos);
r.setSize(drawable->size());
return r;
}
diff --git a/src/widgets/styles/qcommonstyle.cpp b/src/widgets/styles/qcommonstyle.cpp
index 7f0813c303..a9f1c3bbbc 100644
--- a/src/widgets/styles/qcommonstyle.cpp
+++ b/src/widgets/styles/qcommonstyle.cpp
@@ -4251,7 +4251,7 @@ QRect QCommonStyle::subControlRect(ComplexControl cc, const QStyleOptionComplex
if (sc == SC_GroupBoxCheckBox) {
int indicatorHeight = proxy()->pixelMetric(PM_IndicatorHeight, opt, widget);
left = ltr ? totalRect.left() : (totalRect.right() - indicatorWidth);
- int top = totalRect.top() + (fontMetrics.height() - indicatorHeight) / 2;
+ int top = totalRect.top() + qMax(0, fontMetrics.height() - indicatorHeight) / 2;
totalRect.setRect(left, top, indicatorWidth, indicatorHeight);
// Adjust for label
} else {
diff --git a/src/widgets/styles/qmacstyle_mac.mm b/src/widgets/styles/qmacstyle_mac.mm
index 0b860450d1..5db4801c37 100644
--- a/src/widgets/styles/qmacstyle_mac.mm
+++ b/src/widgets/styles/qmacstyle_mac.mm
@@ -2191,7 +2191,6 @@ int QMacStyle::pixelMetric(PixelMetric metric, const QStyleOption *opt, const QW
HIRect rect;
ptrHIShapeGetBounds(region, &rect);
ret = int(rect.size.height);
- ret += 4;
}
break;
case PM_TabBarTabVSpace:
@@ -3791,7 +3790,7 @@ void QMacStyle::drawControl(ControlElement ce, const QStyleOption *opt, QPainter
} else if (!(tabOpt->state & State_Enabled)) {
tdi.style = kThemeTabNonFrontInactive;
} else if (tabOpt->state & State_Sunken) {
- tdi.style = kThemeTabFrontInactive; // (should be kThemeTabNonFrontPressed)
+ tdi.style = kThemeTabNonFrontPressed;
}
if (tabOpt->state & State_HasFocus)
tdi.adornment = kHIThemeTabAdornmentFocus;
@@ -3866,8 +3865,9 @@ void QMacStyle::drawControl(ControlElement ce, const QStyleOption *opt, QPainter
ThemeTabDirection ttd = getTabDirection(myTab.shape);
bool verticalTabs = ttd == kThemeTabWest || ttd == kThemeTabEast;
bool selected = (myTab.state & QStyle::State_Selected);
+ bool usingModernOSX = QSysInfo::MacintoshVersion > QSysInfo::MV_10_6;
- if (selected && !myTab.documentMode)
+ if (usingModernOSX && selected && !myTab.documentMode)
myTab.palette.setColor(QPalette::WindowText, QColor(Qt::white));
// Check to see if we use have the same as the system font
@@ -3875,7 +3875,7 @@ void QMacStyle::drawControl(ControlElement ce, const QStyleOption *opt, QPainter
// outside world, unless they read the source, in which case, it's
// their own fault).
bool nonDefaultFont = p->font() != qt_app_fonts_hash()->value("QComboMenuItem");
- if (selected || verticalTabs || nonDefaultFont || !tab->icon.isNull()
+ if ((usingModernOSX && selected) || verticalTabs || nonDefaultFont || !tab->icon.isNull()
|| !myTab.leftButtonSize.isNull() || !myTab.rightButtonSize.isNull()) {
int heightOffset = 0;
if (verticalTabs) {
@@ -3886,7 +3886,7 @@ void QMacStyle::drawControl(ControlElement ce, const QStyleOption *opt, QPainter
}
myTab.rect.setHeight(myTab.rect.height() + heightOffset);
- if (myTab.documentMode || selected) {
+ if (myTab.documentMode || (usingModernOSX && selected)) {
p->save();
rotateTabPainter(p, myTab.shape, myTab.rect);
diff --git a/src/widgets/styles/qstylesheetstyle.cpp b/src/widgets/styles/qstylesheetstyle.cpp
index 417e092e11..ab98dfbdcf 100644
--- a/src/widgets/styles/qstylesheetstyle.cpp
+++ b/src/widgets/styles/qstylesheetstyle.cpp
@@ -4821,7 +4821,7 @@ QSize QStyleSheetStyle::sizeFromContents(ContentsType ct, const QStyleOption *op
QSize defaultUpSize = defaultSize(w, subRule.size(), spinbox->rect, PseudoElement_SpinBoxUpButton);
sz += QSize(defaultUpSize.width(), 0);
}
- if (rule.hasBox() || !rule.hasNativeBorder())
+ if (rule.hasBox() || rule.hasBorder() || !rule.hasNativeBorder())
sz = rule.boxSize(sz);
return sz;
}
diff --git a/src/widgets/widgets/qdialogbuttonbox.cpp b/src/widgets/widgets/qdialogbuttonbox.cpp
index 9789c453f3..6b183d3759 100644
--- a/src/widgets/widgets/qdialogbuttonbox.cpp
+++ b/src/widgets/widgets/qdialogbuttonbox.cpp
@@ -46,6 +46,7 @@
#include <QtWidgets/qdialog.h>
#include <QtWidgets/qapplication.h>
#include <private/qwidget_p.h>
+#include <QtGui/qpa/qplatformdialoghelper.h>
#include <QtWidgets/qaction.h>
#include "qdialogbuttonbox.h"
@@ -166,46 +167,8 @@ enum {
static QDialogButtonBox::ButtonRole roleFor(QDialogButtonBox::StandardButton button)
{
- switch (button) {
- case QDialogButtonBox::Ok:
- case QDialogButtonBox::Save:
- case QDialogButtonBox::Open:
- case QDialogButtonBox::SaveAll:
- case QDialogButtonBox::Retry:
- case QDialogButtonBox::Ignore:
- return QDialogButtonBox::AcceptRole;
-
- case QDialogButtonBox::Cancel:
- case QDialogButtonBox::Close:
- case QDialogButtonBox::Abort:
- return QDialogButtonBox::RejectRole;
-
- case QDialogButtonBox::Discard:
- return QDialogButtonBox::DestructiveRole;
-
- case QDialogButtonBox::Help:
- return QDialogButtonBox::HelpRole;
-
- case QDialogButtonBox::Apply:
- return QDialogButtonBox::ApplyRole;
-
- case QDialogButtonBox::Yes:
- case QDialogButtonBox::YesToAll:
- return QDialogButtonBox::YesRole;
-
- case QDialogButtonBox::No:
- case QDialogButtonBox::NoToAll:
- return QDialogButtonBox::NoRole;
-
- case QDialogButtonBox::RestoreDefaults:
- case QDialogButtonBox::Reset:
- return QDialogButtonBox::ResetRole;
-
- case QDialogButtonBox::NoButton: // NoButton means zero buttons, not "No" button
- ;
- }
-
- return QDialogButtonBox::InvalidRole;
+ return static_cast<QDialogButtonBox::ButtonRole>(QMessageDialogOptions::buttonRole(
+ static_cast<QMessageDialogOptions::StandardButton>(button)));
}
static const uint layouts[2][5][14] =
diff --git a/src/widgets/widgets/qdockwidget.cpp b/src/widgets/widgets/qdockwidget.cpp
index 8b151e65bd..46929397a0 100644
--- a/src/widgets/widgets/qdockwidget.cpp
+++ b/src/widgets/widgets/qdockwidget.cpp
@@ -455,14 +455,6 @@ int QDockWidgetLayout::titleHeight() const
perp(verticalTitleBar, floatSize));
QFontMetrics titleFontMetrics = q->fontMetrics();
-#ifdef Q_WS_MAC
- if (qobject_cast<QMacStyle *>(q->style())) {
- //### this breaks on proxy styles. (But is this code still called?)
- QFont font = qt_app_fonts_hash()->value("QToolButton", q->font());
- titleFontMetrics = QFontMetrics(font);
- }
-#endif
-
int mw = q->style()->pixelMetric(QStyle::PM_DockWidgetTitleMargin, 0, q);
return qMax(buttonHeight + 2, titleFontMetrics.height() + 2*mw);
diff --git a/src/widgets/widgets/qkeysequenceedit.cpp b/src/widgets/widgets/qkeysequenceedit.cpp
index a1915e41ef..c056967cf7 100644
--- a/src/widgets/widgets/qkeysequenceedit.cpp
+++ b/src/widgets/widgets/qkeysequenceedit.cpp
@@ -50,11 +50,14 @@ QT_BEGIN_NAMESPACE
#ifndef QT_NO_KEYSEQUENCEEDIT
+Q_STATIC_ASSERT(QKeySequencePrivate::MaxKeyCount == 4); // assumed by the code around here
+
void QKeySequenceEditPrivate::init()
{
Q_Q(QKeySequenceEdit);
lineEdit = new QLineEdit(q);
+ lineEdit->setObjectName(QStringLiteral("qt_keysequenceedit_lineedit"));
keyNum = 0;
prevKey = -1;
releaseTimer = 0;
@@ -221,15 +224,7 @@ void QKeySequenceEdit::setKeySequence(const QKeySequence &keySequence)
*/
void QKeySequenceEdit::clear()
{
- Q_D(QKeySequenceEdit);
-
- d->resetState();
-
- d->lineEdit->clear();
- d->keySequence = QKeySequence();
- d->keyNum = d->key[0] = d->key[1] = d->key[2] = d->key[3] = 0;
- d->prevKey = -1;
- emit keySequenceChanged(d->keySequence);
+ setKeySequence(QKeySequence());
}
/*!
@@ -279,7 +274,7 @@ void QKeySequenceEdit::keyPressEvent(QKeyEvent *e)
return;
}
- if (d->keyNum >= QKeySequenceEditPrivate::MaxKeyCount)
+ if (d->keyNum >= QKeySequencePrivate::MaxKeyCount)
return;
nextKey |= d->translateModifiers(e->modifiers(), e->text());
@@ -290,7 +285,7 @@ void QKeySequenceEdit::keyPressEvent(QKeyEvent *e)
QKeySequence key(d->key[0], d->key[1], d->key[2], d->key[3]);
d->keySequence = key;
QString text = key.toString(QKeySequence::NativeText);
- if (d->keyNum < QKeySequenceEditPrivate::MaxKeyCount) {
+ if (d->keyNum < QKeySequencePrivate::MaxKeyCount) {
//: This text is an "unfinished" shortcut, expands like "Ctrl+A, ..."
text = tr("%1, ...").arg(text);
}
@@ -306,7 +301,7 @@ void QKeySequenceEdit::keyReleaseEvent(QKeyEvent *e)
Q_D(QKeySequenceEdit);
if (d->prevKey == e->key()) {
- if (d->keyNum < QKeySequenceEditPrivate::MaxKeyCount)
+ if (d->keyNum < QKeySequencePrivate::MaxKeyCount)
d->releaseTimer = startTimer(1000);
else
d->finishEditing();
diff --git a/src/widgets/widgets/qkeysequenceedit.h b/src/widgets/widgets/qkeysequenceedit.h
index 9312e98d0e..7eeff4e504 100644
--- a/src/widgets/widgets/qkeysequenceedit.h
+++ b/src/widgets/widgets/qkeysequenceedit.h
@@ -53,7 +53,7 @@ class QKeySequenceEditPrivate;
class Q_WIDGETS_EXPORT QKeySequenceEdit : public QWidget
{
Q_OBJECT
- Q_PROPERTY(QKeySequence keySequence READ keySequence WRITE setKeySequence RESET clear NOTIFY keySequenceChanged USER true)
+ Q_PROPERTY(QKeySequence keySequence READ keySequence WRITE setKeySequence NOTIFY keySequenceChanged USER true)
public:
explicit QKeySequenceEdit(QWidget *parent = 0);
@@ -61,9 +61,9 @@ public:
~QKeySequenceEdit();
QKeySequence keySequence() const;
- void setKeySequence(const QKeySequence &keySequence);
public Q_SLOTS:
+ void setKeySequence(const QKeySequence &keySequence);
void clear();
Q_SIGNALS:
diff --git a/src/widgets/widgets/qkeysequenceedit_p.h b/src/widgets/widgets/qkeysequenceedit_p.h
index 58c9699059..f74433bb71 100644
--- a/src/widgets/widgets/qkeysequenceedit_p.h
+++ b/src/widgets/widgets/qkeysequenceedit_p.h
@@ -46,6 +46,7 @@
#include "qkeysequenceedit.h"
#include <private/qwidget_p.h>
+#include <private/qkeysequence_p.h>
QT_BEGIN_NAMESPACE
@@ -57,8 +58,6 @@ class QKeySequenceEditPrivate : public QWidgetPrivate
{
Q_DECLARE_PUBLIC(QKeySequenceEdit)
public:
- enum { MaxKeyCount = 4 };
-
void init();
int translateModifiers(Qt::KeyboardModifiers state, const QString &text);
void resetState();
@@ -67,7 +66,7 @@ public:
QLineEdit *lineEdit;
QKeySequence keySequence;
int keyNum;
- int key[MaxKeyCount];
+ int key[QKeySequencePrivate::MaxKeyCount];
int prevKey;
int releaseTimer;
};
diff --git a/src/widgets/widgets/qlineedit.cpp b/src/widgets/widgets/qlineedit.cpp
index d3c37ab612..df5ae0171c 100644
--- a/src/widgets/widgets/qlineedit.cpp
+++ b/src/widgets/widgets/qlineedit.cpp
@@ -495,12 +495,13 @@ void QLineEdit::setClearButtonEnabled(bool enable)
return;
if (enable) {
QAction *clearAction = new QAction(d->clearButtonIcon(), QString(), this);
+ clearAction->setEnabled(!isReadOnly());
clearAction->setObjectName(QLatin1String(clearButtonActionNameC));
d->addAction(clearAction, 0, QLineEdit::TrailingPosition, QLineEditPrivate::SideWidgetClearButton | QLineEditPrivate::SideWidgetFadeInWithText);
} else {
QAction *clearAction = findChild<QAction *>(QLatin1String(clearButtonActionNameC));
Q_ASSERT(clearAction);
- removeAction(clearAction);
+ d->removeAction(clearAction);
delete clearAction;
}
}
@@ -1336,6 +1337,7 @@ void QLineEdit::setReadOnly(bool enable)
Q_D(QLineEdit);
if (d->control->isReadOnly() != enable) {
d->control->setReadOnly(enable);
+ d->setClearButtonEnabled(!enable);
setAttribute(Qt::WA_MacShowFocusRect, !enable);
setAttribute(Qt::WA_InputMethodEnabled, d->shouldEnableInputMethod());
#ifndef QT_NO_CURSOR
@@ -1439,7 +1441,7 @@ bool QLineEdit::event(QEvent * e)
d->setCursorVisible(true);
}
} else if (e->type() == QEvent::ActionRemoved) {
- d->removeAction(static_cast<QActionEvent *>(e));
+ d->removeAction(static_cast<QActionEvent *>(e)->action());
} else if (e->type() == QEvent::Resize) {
d->positionSideWidgets();
}
diff --git a/src/widgets/widgets/qlineedit_p.cpp b/src/widgets/widgets/qlineedit_p.cpp
index 99d6d0b8d9..891839ed56 100644
--- a/src/widgets/widgets/qlineedit_p.cpp
+++ b/src/widgets/widgets/qlineedit_p.cpp
@@ -376,6 +376,16 @@ QIcon QLineEditPrivate::clearButtonIcon() const
return QIcon(q->style()->standardPixmap(QStyle::SP_LineEditClearButton, &styleOption, q));
}
+void QLineEditPrivate::setClearButtonEnabled(bool enabled)
+{
+ foreach (const SideWidgetEntry &e, trailingSideWidgets) {
+ if (e.flags & SideWidgetClearButton) {
+ e.action->setEnabled(enabled);
+ break;
+ }
+ }
+}
+
void QLineEditPrivate::positionSideWidgets()
{
Q_Q(QLineEdit);
@@ -445,10 +455,9 @@ QWidget *QLineEditPrivate::addAction(QAction *newAction, QAction *before, QLineE
return w;
}
-void QLineEditPrivate::removeAction(const QActionEvent *e)
+void QLineEditPrivate::removeAction(QAction *action)
{
Q_Q(QLineEdit);
- QAction *action = e->action();
const PositionIndexPair positionIndex = findSideWidget(action);
if (positionIndex.second == -1)
return;
diff --git a/src/widgets/widgets/qlineedit_p.h b/src/widgets/widgets/qlineedit_p.h
index 8fe45972ff..181a23449b 100644
--- a/src/widgets/widgets/qlineedit_p.h
+++ b/src/widgets/widgets/qlineedit_p.h
@@ -196,9 +196,10 @@ public:
QString placeholderText;
QWidget *addAction(QAction *newAction, QAction *before, QLineEdit::ActionPosition, int flags = 0);
- void removeAction(const QActionEvent *e);
+ void removeAction(QAction *action);
QSize iconSize() const;
QIcon clearButtonIcon() const;
+ void setClearButtonEnabled(bool enabled);
void positionSideWidgets();
inline bool hasSideWidgets() const { return !leadingSideWidgets.isEmpty() || !trailingSideWidgets.isEmpty(); }
inline const SideWidgetEntryList &leftSideWidgetList() const
diff --git a/src/widgets/widgets/qmdiarea.cpp b/src/widgets/widgets/qmdiarea.cpp
index ea33f40806..600d9b536f 100644
--- a/src/widgets/widgets/qmdiarea.cpp
+++ b/src/widgets/widgets/qmdiarea.cpp
@@ -354,11 +354,6 @@ void SimpleCascader::rearrange(QList<QWidget *> &widgets, const QRect &domain) c
QStyleOptionTitleBar options;
options.initFrom(widgets.at(0));
int titleBarHeight = widgets.at(0)->style()->pixelMetric(QStyle::PM_TitleBarHeight, &options, widgets.at(0));
-#if defined(Q_WS_MAC) && !defined(QT_NO_STYLE_MAC)
- // ### Remove this after the mac style has been fixed
- if (qobject_cast<QMacStyle *>(widgets.at(0)->style()))
- titleBarHeight -= 4;
-#endif
const QFontMetrics fontMetrics = QFontMetrics(QApplication::font("QMdiSubWindowTitleBar"));
const int dy = qMax(titleBarHeight - (titleBarHeight - fontMetrics.height()) / 2, 1);
diff --git a/src/widgets/widgets/qmdisubwindow.cpp b/src/widgets/widgets/qmdisubwindow.cpp
index b80eb069e2..8e1dcbee18 100644
--- a/src/widgets/widgets/qmdisubwindow.cpp
+++ b/src/widgets/widgets/qmdisubwindow.cpp
@@ -1710,11 +1710,6 @@ int QMdiSubWindowPrivate::titleBarHeight(const QStyleOptionTitleBar &options) co
}
int height = q->style()->pixelMetric(QStyle::PM_TitleBarHeight, &options, q);
-#if defined(Q_OS_MAC) && !defined(QT_NO_STYLE_MAC)
- // ### Fix mac style, the +4 pixels hack is not necessary anymore
- if (qobject_cast<QMacStyle *>(q->style()))
- height -= 4;
-#endif
if (hasBorder(options))
height += q->isMinimized() ? 8 : 4;
return height;
diff --git a/src/widgets/widgets/qscrollarea.h b/src/widgets/widgets/qscrollarea.h
index 70af5fbbd7..db1083f122 100644
--- a/src/widgets/widgets/qscrollarea.h
+++ b/src/widgets/widgets/qscrollarea.h
@@ -69,7 +69,6 @@ public:
void setWidgetResizable(bool resizable);
QSize sizeHint() const;
- QSize viewportSizeHint() const;
bool focusNextPrevChild(bool next);
@@ -86,6 +85,8 @@ protected:
void resizeEvent(QResizeEvent *);
void scrollContentsBy(int dx, int dy);
+ QSize viewportSizeHint() const Q_DECL_OVERRIDE;
+
private:
Q_DECLARE_PRIVATE(QScrollArea)
Q_DISABLE_COPY(QScrollArea)
diff --git a/src/widgets/widgets/qtabbar.cpp b/src/widgets/widgets/qtabbar.cpp
index 094e9af0de..dfd1f1022c 100644
--- a/src/widgets/widgets/qtabbar.cpp
+++ b/src/widgets/widgets/qtabbar.cpp
@@ -1496,6 +1496,12 @@ bool QTabBar::event(QEvent *event)
}
}
#endif
+ } else if (event->type() == QEvent::MouseButtonDblClick) { // ### fixme Qt 6: move to mouseDoubleClickEvent(), here for BC reasons.
+ const QPoint pos = static_cast<const QMouseEvent *>(event)->pos();
+ const bool isEventInCornerButtons = (!d->leftB->isHidden() && d->leftB->geometry().contains(pos))
+ || (!d->rightB->isHidden() && d->rightB->geometry().contains(pos));
+ if (!isEventInCornerButtons)
+ emit tabBarDoubleClicked(tabAt(pos));
}
return QWidget::event(event);
}
@@ -1723,23 +1729,6 @@ void QTabBarPrivate::moveTab(int index, int offset)
q_func()->update();
}
-
-/*!
- \reimp
-*/
-void QTabBar::mouseDoubleClickEvent(QMouseEvent *event)
-{
- Q_D(QTabBar);
-
- const QPoint pos = event->pos();
- const bool isEventInCornerButtons = (!d->leftB->isHidden() && d->leftB->geometry().contains(pos))
- || (!d->rightB->isHidden() && d->rightB->geometry().contains(pos));
- if (!isEventInCornerButtons) {
- const int index = tabAt(pos);
- emit tabBarDoubleClicked(index);
- }
-}
-
/*!\reimp
*/
void QTabBar::mousePressEvent(QMouseEvent *event)
diff --git a/src/widgets/widgets/qtabbar.h b/src/widgets/widgets/qtabbar.h
index 1f7b8f6b03..a0e52c2f86 100644
--- a/src/widgets/widgets/qtabbar.h
+++ b/src/widgets/widgets/qtabbar.h
@@ -188,7 +188,6 @@ protected:
void showEvent(QShowEvent *);
void hideEvent(QHideEvent *);
void paintEvent(QPaintEvent *);
- void mouseDoubleClickEvent(QMouseEvent *);
void mousePressEvent (QMouseEvent *);
void mouseMoveEvent (QMouseEvent *);
void mouseReleaseEvent (QMouseEvent *);
diff --git a/src/widgets/widgets/qtextedit.cpp b/src/widgets/widgets/qtextedit.cpp
index 0f61eb487f..49e05e8e14 100644
--- a/src/widgets/widgets/qtextedit.cpp
+++ b/src/widgets/widgets/qtextedit.cpp
@@ -1513,6 +1513,14 @@ void QTextEditPrivate::paint(QPainter *p, QPaintEvent *e)
if (layout)
layout->setViewport(QRect());
+
+ if (!placeholderText.isEmpty() && doc->isEmpty()) {
+ QColor col = control->palette().text().color();
+ col.setAlpha(128);
+ p->setPen(col);
+ const int margin = int(doc->documentMargin());
+ p->drawText(viewport->rect().adjusted(margin, margin, -margin, -margin), Qt::AlignTop | Qt::TextWordWrap, placeholderText);
+ }
}
/*! \fn void QTextEdit::paintEvent(QPaintEvent *event)
@@ -1528,13 +1536,6 @@ void QTextEdit::paintEvent(QPaintEvent *e)
Q_D(QTextEdit);
QPainter p(d->viewport);
d->paint(&p, e);
- if (!d->placeholderText.isEmpty() && d->control->document()->isEmpty()) {
- QColor col = palette().text().color();
- col.setAlpha(128);
- p.setPen(col);
- const int margin = int(document()->documentMargin());
- p.drawText(d->viewport->rect().adjusted(margin, margin, -margin, -margin), Qt::AlignTop | Qt::TextWordWrap, d->placeholderText);
- }
}
void QTextEditPrivate::_q_currentCharFormatChanged(const QTextCharFormat &fmt)