diff options
author | Frederik Gladhorn <frederik.gladhorn@digia.com> | 2013-11-26 22:30:27 +0100 |
---|---|---|
committer | Frederik Gladhorn <frederik.gladhorn@digia.com> | 2013-11-26 22:35:48 +0100 |
commit | 4a8273a6fc2e741e811cf5dabc9a3c240306cf7f (patch) | |
tree | 2148abc88f8543eecdc0b97b2dd92594836af9b2 /src/widgets/widgets | |
parent | 036c5db468164297d213764c59a4b59daa76d90a (diff) | |
parent | 1c2be58fecaff1de5f2849192eb712984ebd59bd (diff) |
Merge remote-tracking branch 'origin/stable' into dev
For the conflicts in msvc_nmake.cpp the ifdefs are extended since we
need to support windows phone in the target branch while it is not there
in the current stable branch (as of Qt 5.2).
Conflicts:
configure
qmake/generators/win32/msvc_nmake.cpp
src/3rdparty/angle/src/libEGL/Surface.cpp
src/angle/src/common/common.pri
src/corelib/global/qglobal.h
src/corelib/io/qstandardpaths.cpp
src/plugins/platforms/qnx/qqnxintegration.cpp
src/plugins/platforms/qnx/qqnxscreeneventhandler.h
src/plugins/platforms/xcb/qglxintegration.h
src/widgets/kernel/win.pri
tests/auto/corelib/thread/qreadwritelock/tst_qreadwritelock.cpp
tests/auto/corelib/tools/qdatetime/tst_qdatetime.cpp
tests/auto/gui/text/qtextdocument/tst_qtextdocument.cpp
tools/configure/configureapp.cpp
Change-Id: I00b579eefebaf61d26ab9b00046d2b5bd5958812
Diffstat (limited to 'src/widgets/widgets')
-rw-r--r-- | src/widgets/widgets/qdialogbuttonbox.cpp | 43 | ||||
-rw-r--r-- | src/widgets/widgets/qdockwidget.cpp | 8 | ||||
-rw-r--r-- | src/widgets/widgets/qkeysequenceedit.cpp | 19 | ||||
-rw-r--r-- | src/widgets/widgets/qkeysequenceedit.h | 4 | ||||
-rw-r--r-- | src/widgets/widgets/qkeysequenceedit_p.h | 5 | ||||
-rw-r--r-- | src/widgets/widgets/qlineedit.cpp | 6 | ||||
-rw-r--r-- | src/widgets/widgets/qlineedit_p.cpp | 13 | ||||
-rw-r--r-- | src/widgets/widgets/qlineedit_p.h | 3 | ||||
-rw-r--r-- | src/widgets/widgets/qmdiarea.cpp | 5 | ||||
-rw-r--r-- | src/widgets/widgets/qmdisubwindow.cpp | 5 | ||||
-rw-r--r-- | src/widgets/widgets/qscrollarea.h | 3 | ||||
-rw-r--r-- | src/widgets/widgets/qtabbar.cpp | 23 | ||||
-rw-r--r-- | src/widgets/widgets/qtabbar.h | 1 | ||||
-rw-r--r-- | src/widgets/widgets/qtextedit.cpp | 15 |
14 files changed, 47 insertions, 106 deletions
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) |