diff options
Diffstat (limited to 'src/widgets/widgets')
29 files changed, 152 insertions, 184 deletions
diff --git a/src/widgets/widgets/qabstractspinbox.cpp b/src/widgets/widgets/qabstractspinbox.cpp index 25369a01b6..92af91b66e 100644 --- a/src/widgets/widgets/qabstractspinbox.cpp +++ b/src/widgets/widgets/qabstractspinbox.cpp @@ -396,6 +396,30 @@ bool QAbstractSpinBox::isAccelerated() const } /*! + \property QAbstractSpinBox::showGroupSeparator + \since 5.3 + + + This property holds whether a thousands separator is enabled. By default this + property is false. +*/ +bool QAbstractSpinBox::isGroupSeparatorShown() const +{ + Q_D(const QAbstractSpinBox); + return d->showGroupSeparator; +} + +void QAbstractSpinBox::setGroupSeparatorShown(bool shown) +{ + Q_D(QAbstractSpinBox); + if (d->showGroupSeparator == shown) + return; + d->showGroupSeparator = shown; + d->setValue(d->value, EmitIfChanged); + updateGeometry(); +} + +/*! \enum QAbstractSpinBox::CorrectionMode This enum type describes the mode the spinbox will use to correct @@ -1316,7 +1340,8 @@ QAbstractSpinBoxPrivate::QAbstractSpinBoxPrivate() cachedState(QValidator::Invalid), pendingEmit(false), readOnly(false), wrapping(false), ignoreCursorPositionChanged(false), frame(true), accelerate(false), keyboardTracking(true), cleared(false), ignoreUpdateEdit(false), correctionMode(QAbstractSpinBox::CorrectToPreviousValue), - acceleration(0), hoverControl(QStyle::SC_None), buttonSymbols(QAbstractSpinBox::UpDownArrows), validator(0) + acceleration(0), hoverControl(QStyle::SC_None), buttonSymbols(QAbstractSpinBox::UpDownArrows), validator(0), + showGroupSeparator(0) { } @@ -1491,13 +1516,12 @@ void QAbstractSpinBoxPrivate::_q_editorCursorPositionChanged(int oldpos, int new * (newpos < pos ? -1 : 1)) - newpos + pos : 0; - const bool wasBlocked = edit->blockSignals(true); + const QSignalBlocker blocker(edit); if (selSize != 0) { edit->setSelection(pos - selSize, selSize); } else { edit->setCursorPosition(pos); } - edit->blockSignals(wasBlocked); } ignoreCursorPositionChanged = false; } @@ -1697,7 +1721,7 @@ void QAbstractSpinBoxPrivate::updateEdit() const bool empty = edit->text().isEmpty(); int cursor = edit->cursorPosition(); int selsize = edit->selectedText().size(); - const bool sb = edit->blockSignals(true); + const QSignalBlocker blocker(edit); edit->setText(newText); if (!specialValue()) { @@ -1709,7 +1733,6 @@ void QAbstractSpinBoxPrivate::updateEdit() edit->setCursorPosition(empty ? prefix.size() : cursor); } } - edit->blockSignals(sb); q->update(); } diff --git a/src/widgets/widgets/qabstractspinbox.h b/src/widgets/widgets/qabstractspinbox.h index 4f6aad0cde..7989000cc8 100644 --- a/src/widgets/widgets/qabstractspinbox.h +++ b/src/widgets/widgets/qabstractspinbox.h @@ -72,6 +72,7 @@ class Q_WIDGETS_EXPORT QAbstractSpinBox : public QWidget Q_PROPERTY(CorrectionMode correctionMode READ correctionMode WRITE setCorrectionMode) Q_PROPERTY(bool acceptableInput READ hasAcceptableInput) Q_PROPERTY(bool keyboardTracking READ keyboardTracking WRITE setKeyboardTracking) + Q_PROPERTY(bool showGroupSeparator READ isGroupSeparatorShown WRITE setGroupSeparatorShown) public: explicit QAbstractSpinBox(QWidget *parent = 0); ~QAbstractSpinBox(); @@ -114,6 +115,9 @@ public: void setAccelerated(bool on); bool isAccelerated() const; + void setGroupSeparatorShown(bool shown); + bool isGroupSeparatorShown() const; + QSize sizeHint() const; QSize minimumSizeHint() const; void interpretText(); diff --git a/src/widgets/widgets/qabstractspinbox_p.h b/src/widgets/widgets/qabstractspinbox_p.h index 0eeec02abc..da9f1d9757 100644 --- a/src/widgets/widgets/qabstractspinbox_p.h +++ b/src/widgets/widgets/qabstractspinbox_p.h @@ -150,6 +150,7 @@ public: QRect hoverRect; QAbstractSpinBox::ButtonSymbols buttonSymbols; QSpinBoxValidator *validator; + uint showGroupSeparator : 1; }; class QSpinBoxValidator : public QValidator diff --git a/src/widgets/widgets/qcombobox.cpp b/src/widgets/widgets/qcombobox.cpp index 2c09f5a8f1..17a6ededfe 100644 --- a/src/widgets/widgets/qcombobox.cpp +++ b/src/widgets/widgets/qcombobox.cpp @@ -2608,9 +2608,9 @@ void QComboBox::hidePopup() Q_D(QComboBox); if (d->container && d->container->isVisible()) { #if !defined(QT_NO_EFFECTS) - d->model->blockSignals(true); - d->container->itemView()->blockSignals(true); - d->container->blockSignals(true); + QSignalBlocker modelBlocker(d->model); + QSignalBlocker viewBlocker(d->container->itemView()); + QSignalBlocker containerBlocker(d->container); // Flash selected/triggered item (if any). if (style()->styleHint(QStyle::SH_Menu_FlashTriggeredItem)) { QItemSelectionModel *selectionModel = view() ? view()->selectionModel() : 0; @@ -2646,9 +2646,9 @@ void QComboBox::hidePopup() #endif // Q_OS_MAC // Other platform implementations welcome :-) } - d->model->blockSignals(false); - d->container->itemView()->blockSignals(false); - d->container->blockSignals(false); + containerBlocker.unblock(); + viewBlocker.unblock(); + modelBlocker.unblock(); if (!didFade) #endif // QT_NO_EFFECTS diff --git a/src/widgets/widgets/qdatetimeedit.cpp b/src/widgets/widgets/qdatetimeedit.cpp index a0bbbbf7c7..7a723c5f1f 100644 --- a/src/widgets/widgets/qdatetimeedit.cpp +++ b/src/widgets/widgets/qdatetimeedit.cpp @@ -1718,7 +1718,7 @@ void QDateTimeEditPrivate::updateEdit() if (newText == displayText()) return; int selsize = edit->selectedText().size(); - const bool sb = edit->blockSignals(true); + const QSignalBlocker blocker(edit); edit->setText(newText); @@ -1740,7 +1740,6 @@ void QDateTimeEditPrivate::updateEdit() } } - edit->blockSignals(sb); } @@ -1871,7 +1870,7 @@ void QDateTimeEditPrivate::clearSection(int index) { const QLatin1Char space(' '); int cursorPos = edit->cursorPosition(); - bool blocked = edit->blockSignals(true); + const QSignalBlocker blocker(edit); QString t = edit->text(); const int pos = sectionPos(index); if (pos == -1) { @@ -1883,8 +1882,6 @@ void QDateTimeEditPrivate::clearSection(int index) edit->setText(t); edit->setCursorPosition(cursorPos); QDTEDEBUG << cursorPos; - - edit->blockSignals(blocked); } @@ -2313,7 +2310,7 @@ void QDateTimeEdit::paintEvent(QPaintEvent *event) optCombo.init(this); optCombo.editable = true; - optCombo.frame = opt.frame; + optCombo.frame = opt.frame; optCombo.subControls = opt.subControls; optCombo.activeSubControls = opt.activeSubControls; optCombo.state = opt.state; @@ -2574,10 +2571,9 @@ void QDateTimeEditPrivate::syncCalendarWidget() { Q_Q(QDateTimeEdit); if (monthCalendar) { - const bool sb = monthCalendar->blockSignals(true); + const QSignalBlocker blocker(monthCalendar); monthCalendar->setDateRange(q->minimumDate(), q->maximumDate()); monthCalendar->setDate(q->date()); - monthCalendar->blockSignals(sb); } } diff --git a/src/widgets/widgets/qdialogbuttonbox.cpp b/src/widgets/widgets/qdialogbuttonbox.cpp index 6b183d3759..d28fb66551 100644 --- a/src/widgets/widgets/qdialogbuttonbox.cpp +++ b/src/widgets/widgets/qdialogbuttonbox.cpp @@ -46,7 +46,9 @@ #include <QtWidgets/qdialog.h> #include <QtWidgets/qapplication.h> #include <private/qwidget_p.h> +#include <private/qguiapplication_p.h> #include <QtGui/qpa/qplatformdialoghelper.h> +#include <QtGui/qpa/qplatformtheme.h> #include <QtWidgets/qaction.h> #include "qdialogbuttonbox.h" @@ -246,7 +248,6 @@ public: void _q_handleButtonClicked(); void addButtonsToLayout(const QList<QAbstractButton *> &buttonList, bool reverse); void retranslateStrings(); - const char *standardButtonText(QDialogButtonBox::StandardButton sbutton) const; }; QDialogButtonBoxPrivate::QDialogButtonBoxPrivate(Qt::Orientation orient) @@ -428,7 +429,6 @@ QPushButton *QDialogButtonBoxPrivate::createButton(QDialogButtonBox::StandardBut bool doLayout) { Q_Q(QDialogButtonBox); - const char *buttonText = 0; int icon = 0; switch (sbutton) { @@ -477,9 +477,7 @@ QPushButton *QDialogButtonBoxPrivate::createButton(QDialogButtonBox::StandardBut return 0; ; } - buttonText = standardButtonText(sbutton); - - QPushButton *button = new QPushButton(QDialogButtonBox::tr(buttonText), q); + QPushButton *button = new QPushButton(QGuiApplicationPrivate::platformTheme()->standardButtonText(sbutton), q); QStyle *style = q->style(); if (style->styleHint(QStyle::SH_DialogButtonBox_ButtonsHaveIcons, 0, q) && icon != 0) button->setIcon(style->standardIcon(QStyle::StandardPixmap(icon), 0, q)); @@ -525,87 +523,15 @@ void QDialogButtonBoxPrivate::createStandardButtons(QDialogButtonBox::StandardBu layoutButtons(); } -const char *QDialogButtonBoxPrivate::standardButtonText(QDialogButtonBox::StandardButton sbutton) const -{ - const char *buttonText = 0; - bool gnomeLayout = (layoutPolicy == QDialogButtonBox::GnomeLayout); - switch (sbutton) { - case QDialogButtonBox::Ok: - buttonText = gnomeLayout ? QT_TRANSLATE_NOOP("QDialogButtonBox", "&OK") : QT_TRANSLATE_NOOP("QDialogButtonBox", "OK"); - break; - case QDialogButtonBox::Save: - buttonText = gnomeLayout ? QT_TRANSLATE_NOOP("QDialogButtonBox", "&Save") : QT_TRANSLATE_NOOP("QDialogButtonBox", "Save"); - break; - case QDialogButtonBox::Open: - buttonText = QT_TRANSLATE_NOOP("QDialogButtonBox", "Open"); - break; - case QDialogButtonBox::Cancel: - buttonText = gnomeLayout ? QT_TRANSLATE_NOOP("QDialogButtonBox", "&Cancel") : QT_TRANSLATE_NOOP("QDialogButtonBox", "Cancel"); - break; - case QDialogButtonBox::Close: - buttonText = gnomeLayout ? QT_TRANSLATE_NOOP("QDialogButtonBox", "&Close") : QT_TRANSLATE_NOOP("QDialogButtonBox", "Close"); - break; - case QDialogButtonBox::Apply: - buttonText = QT_TRANSLATE_NOOP("QDialogButtonBox", "Apply"); - break; - case QDialogButtonBox::Reset: - buttonText = QT_TRANSLATE_NOOP("QDialogButtonBox", "Reset"); - break; - case QDialogButtonBox::Help: - buttonText = QT_TRANSLATE_NOOP("QDialogButtonBox", "Help"); - break; - case QDialogButtonBox::Discard: - if (layoutPolicy == QDialogButtonBox::MacLayout) - buttonText = QT_TRANSLATE_NOOP("QDialogButtonBox", "Don't Save"); - else if (layoutPolicy == QDialogButtonBox::GnomeLayout) - buttonText = QT_TRANSLATE_NOOP("QDialogButtonBox", "Close without Saving"); - else - buttonText = QT_TRANSLATE_NOOP("QDialogButtonBox", "Discard"); - break; - case QDialogButtonBox::Yes: - buttonText = QT_TRANSLATE_NOOP("QDialogButtonBox", "&Yes"); - break; - case QDialogButtonBox::YesToAll: - buttonText = QT_TRANSLATE_NOOP("QDialogButtonBox", "Yes to &All"); - break; - case QDialogButtonBox::No: - buttonText = QT_TRANSLATE_NOOP("QDialogButtonBox", "&No"); - break; - case QDialogButtonBox::NoToAll: - buttonText = QT_TRANSLATE_NOOP("QDialogButtonBox", "N&o to All"); - break; - case QDialogButtonBox::SaveAll: - buttonText = QT_TRANSLATE_NOOP("QDialogButtonBox", "Save All"); - break; - case QDialogButtonBox::Abort: - buttonText = QT_TRANSLATE_NOOP("QDialogButtonBox", "Abort"); - break; - case QDialogButtonBox::Retry: - buttonText = QT_TRANSLATE_NOOP("QDialogButtonBox", "Retry"); - break; - case QDialogButtonBox::Ignore: - buttonText = QT_TRANSLATE_NOOP("QDialogButtonBox", "Ignore"); - break; - case QDialogButtonBox::RestoreDefaults: - buttonText = QT_TRANSLATE_NOOP("QDialogButtonBox", "Restore Defaults"); - break; - case QDialogButtonBox::NoButton: - ; - } // switch - return buttonText; -} - void QDialogButtonBoxPrivate::retranslateStrings() { - const char *buttonText = 0; - QHash<QPushButton *, QDialogButtonBox::StandardButton>::iterator it = standardButtonHash.begin(); - while (it != standardButtonHash.end()) { - buttonText = standardButtonText(it.value()); - if (buttonText) { - QPushButton *button = it.key(); - button->setText(QDialogButtonBox::tr(buttonText)); - } - ++it; + typedef QHash<QPushButton *, QDialogButtonBox::StandardButton>::iterator Iterator; + + const Iterator end = standardButtonHash.end(); + for (Iterator it = standardButtonHash.begin(); it != end; ++it) { + const QString text = QGuiApplicationPrivate::platformTheme()->standardButtonText(it.value()); + if (!text.isEmpty()) + it.key()->setText(text); } } diff --git a/src/widgets/widgets/qdockarealayout.cpp b/src/widgets/widgets/qdockarealayout.cpp index 72a463b30b..066b3c7a86 100644 --- a/src/widgets/widgets/qdockarealayout.cpp +++ b/src/widgets/widgets/qdockarealayout.cpp @@ -1940,9 +1940,9 @@ bool QDockAreaLayoutInfo::restoreState(QDataStream &stream, QList<QDockWidget*> } else { QDockAreaLayoutItem item(new QDockWidgetItem(widget)); if (flags & StateFlagFloating) { - bool drawer = false; + bool drawer = false; #ifdef Q_WS_MAC // drawer support - extern bool qt_mac_is_macdrawer(const QWidget *); //qwidget_mac.cpp + extern bool qt_mac_is_macdrawer(const QWidget *); //qwidget_mac.cpp extern bool qt_mac_set_drawer_preferred_edge(QWidget *, Qt::DockWidgetArea); //qwidget_mac.cpp drawer = qt_mac_is_macdrawer(widget); #endif @@ -1988,10 +1988,10 @@ bool QDockAreaLayoutInfo::restoreState(QDataStream &stream, QList<QDockWidget*> emit widget->dockLocationChanged(toDockWidgetArea(dockPos)); } } - if (testing) { - //was it is not really added to the layout, we need to delete the object here - delete item.widgetItem; - } + if (testing) { + //was it is not really added to the layout, we need to delete the object here + delete item.widgetItem; + } } } else if (nextMarker == SequenceMarker) { int dummy; @@ -2096,7 +2096,7 @@ bool QDockAreaLayoutInfo::updateTabBar() const that->tabBar->setDrawBase(true); } - bool blocked = tabBar->blockSignals(true); + const QSignalBlocker blocker(tabBar); bool gap = false; int tab_idx = 0; @@ -2147,8 +2147,6 @@ bool QDockAreaLayoutInfo::updateTabBar() const tabBar->removeTab(tab_idx); } - tabBar->blockSignals(blocked); - //returns if the tabbar is visible or not return ( (gap ? 1 : 0) + tabBar->count()) > 1; } diff --git a/src/widgets/widgets/qdockwidget.cpp b/src/widgets/widgets/qdockwidget.cpp index 46929397a0..ea7fea540f 100644 --- a/src/widgets/widgets/qdockwidget.cpp +++ b/src/widgets/widgets/qdockwidget.cpp @@ -1104,8 +1104,8 @@ void QDockWidgetPrivate::setWindowState(bool floating, bool unplug, const QRect \enum QDockWidget::DockWidgetFeature \value DockWidgetClosable The dock widget can be closed. On some systems the dock - widget always has a close button when it's floating - (for example on MacOS 10.5). + widget always has a close button when it's floating + (for example on MacOS 10.5). \value DockWidgetMovable The dock widget can be moved between docks by the user. \value DockWidgetFloatable The dock widget can be detached from the diff --git a/src/widgets/widgets/qdockwidget_p.h b/src/widgets/widgets/qdockwidget_p.h index 800f523825..f7cd8c0039 100644 --- a/src/widgets/widgets/qdockwidget_p.h +++ b/src/widgets/widgets/qdockwidget_p.h @@ -84,7 +84,7 @@ class QDockWidgetPrivate : public QWidgetPrivate public: inline QDockWidgetPrivate() - : QWidgetPrivate(), state(0), + : QWidgetPrivate(), state(0), features(QDockWidget::DockWidgetClosable | QDockWidget::DockWidgetMovable | QDockWidget::DockWidgetFloatable), diff --git a/src/widgets/widgets/qeffects.cpp b/src/widgets/widgets/qeffects.cpp index 83060bb571..cd8ae81ace 100644 --- a/src/widgets/widgets/qeffects.cpp +++ b/src/widgets/widgets/qeffects.cpp @@ -189,32 +189,32 @@ bool QAlphaWidget::eventFilter(QObject *o, QEvent *e) { switch (e->type()) { case QEvent::Move: - if (o != widget) - break; - move(widget->geometry().x(),widget->geometry().y()); - update(); - break; + if (o != widget) + break; + move(widget->geometry().x(),widget->geometry().y()); + update(); + break; case QEvent::Hide: case QEvent::Close: - if (o != widget) - break; + if (o != widget) + break; case QEvent::MouseButtonPress: - case QEvent::MouseButtonDblClick: - showWidget = false; - render(); - break; + case QEvent::MouseButtonDblClick: + showWidget = false; + render(); + break; case QEvent::KeyPress: { - QKeyEvent *ke = (QKeyEvent*)e; - if (ke->key() == Qt::Key_Escape) { - showWidget = false; - } else { - duration = 0; - } - render(); - break; - } + QKeyEvent *ke = (QKeyEvent*)e; + if (ke->key() == Qt::Key_Escape) { + showWidget = false; + } else { + duration = 0; + } + render(); + break; + } default: - break; + break; } return QWidget::eventFilter(o, e); } diff --git a/src/widgets/widgets/qfontcombobox.cpp b/src/widgets/widgets/qfontcombobox.cpp index 0b0efa2bdf..2bbf3730db 100644 --- a/src/widgets/widgets/qfontcombobox.cpp +++ b/src/widgets/widgets/qfontcombobox.cpp @@ -346,9 +346,10 @@ void QFontComboBoxPrivate::_q_updateModel() //this prevents the current index from changing //it will be updated just after this ///TODO: we should finda way to avoid blocking signals and have a real update of the model - const bool old = m->blockSignals(true); - m->setStringList(list); - m->blockSignals(old); + { + const QSignalBlocker blocker(m); + m->setStringList(list); + } if (list.isEmpty()) { if (currentFont != QFont()) { diff --git a/src/widgets/widgets/qlcdnumber.h b/src/widgets/widgets/qlcdnumber.h index 3dde1527f2..ba7b2d8494 100644 --- a/src/widgets/widgets/qlcdnumber.h +++ b/src/widgets/widgets/qlcdnumber.h @@ -43,7 +43,6 @@ #define QLCDNUMBER_H #include <QtWidgets/qframe.h> -#include <QtCore/qbitarray.h> QT_BEGIN_NAMESPACE diff --git a/src/widgets/widgets/qlineedit.cpp b/src/widgets/widgets/qlineedit.cpp index df5ae0171c..1833dce40b 100644 --- a/src/widgets/widgets/qlineedit.cpp +++ b/src/widgets/widgets/qlineedit.cpp @@ -333,7 +333,12 @@ void QLineEdit::setText(const QString& text) \brief the line edit's placeholder text Setting this property makes the line edit display a grayed-out - placeholder text as long as the text() is empty. + placeholder text as long as the line edit is empty. + + Normally, an empty line edit shows the placeholder text even + when it has focus. However, if the content is horizontally + centered, the placeholder text is not displayed under + the cursor when the line edit has focus. By default, this property contains an empty string. @@ -350,7 +355,7 @@ void QLineEdit::setPlaceholderText(const QString& placeholderText) Q_D(QLineEdit); if (d->placeholderText != placeholderText) { d->placeholderText = placeholderText; - if (d->control->text().isEmpty()) + if (d->shouldShowPlaceholderText()) update(); } } @@ -1895,7 +1900,7 @@ void QLineEdit::paintEvent(QPaintEvent *) int minLB = qMax(0, -fm.minLeftBearing()); int minRB = qMax(0, -fm.minRightBearing()); - if (d->control->text().isEmpty() && d->control->preeditAreaText().isEmpty()) { + if (d->shouldShowPlaceholderText()) { if (!d->placeholderText.isEmpty()) { QColor col = pal.text().color(); col.setAlpha(128); diff --git a/src/widgets/widgets/qlineedit_p.h b/src/widgets/widgets/qlineedit_p.h index 181a23449b..aa5b57a920 100644 --- a/src/widgets/widgets/qlineedit_p.h +++ b/src/widgets/widgets/qlineedit_p.h @@ -148,6 +148,11 @@ public: { return !control->isReadOnly(); } + inline bool shouldShowPlaceholderText() const + { + return control->text().isEmpty() && control->preeditAreaText().isEmpty() + && !((alignment & Qt::AlignHCenter) && q_func()->hasFocus()); + } static inline QLineEditPrivate *get(QLineEdit *lineEdit) { return lineEdit->d_func(); diff --git a/src/widgets/widgets/qmdiarea.cpp b/src/widgets/widgets/qmdiarea.cpp index 349d8c3423..600d9b536f 100644 --- a/src/widgets/widgets/qmdiarea.cpp +++ b/src/widgets/widgets/qmdiarea.cpp @@ -1115,10 +1115,9 @@ void QMdiAreaPrivate::updateActiveWindow(int removedIndex, bool activeRemoved) #ifndef QT_NO_TABBAR if (tabBar && removedIndex >= 0) { - tabBar->blockSignals(true); + const QSignalBlocker blocker(tabBar); tabBar->removeTab(removedIndex); updateTabBarGeometry(); - tabBar->blockSignals(false); } #endif diff --git a/src/widgets/widgets/qmenu.cpp b/src/widgets/widgets/qmenu.cpp index 3a4fd449c8..d1b0da1a55 100644 --- a/src/widgets/widgets/qmenu.cpp +++ b/src/widgets/widgets/qmenu.cpp @@ -435,7 +435,7 @@ void QMenuPrivate::hideMenu(QMenu *menu) if (!menu) return; #if !defined(QT_NO_EFFECTS) - menu->blockSignals(true); + QSignalBlocker blocker(menu); aboutToHide = true; // Flash item which is about to trigger (if any). if (menu->style()->styleHint(QStyle::SH_Menu_FlashTriggeredItem) @@ -455,7 +455,7 @@ void QMenuPrivate::hideMenu(QMenu *menu) } aboutToHide = false; - menu->blockSignals(false); + blocker.unblock(); #endif // QT_NO_EFFECTS menu->close(); } diff --git a/src/widgets/widgets/qmenubar.cpp b/src/widgets/widgets/qmenubar.cpp index 9c1e2f0516..189f4c456b 100644 --- a/src/widgets/widgets/qmenubar.cpp +++ b/src/widgets/widgets/qmenubar.cpp @@ -1833,9 +1833,9 @@ void QMenuBar::setNativeMenuBar(bool nativeMenuBar) d->platformMenuBar = QGuiApplicationPrivate::platformTheme()->createPlatformMenuBar(); } - updateGeometry(); - if (!d->nativeMenuBar && parentWidget()) - setVisible(true); + updateGeometry(); + if (!d->nativeMenuBar && parentWidget()) + setVisible(true); } } diff --git a/src/widgets/widgets/qplaintextedit.cpp b/src/widgets/widgets/qplaintextedit.cpp index 90f2e47cd3..2f576a4e39 100644 --- a/src/widgets/widgets/qplaintextedit.cpp +++ b/src/widgets/widgets/qplaintextedit.cpp @@ -347,7 +347,7 @@ void QPlainTextDocumentLayout::documentChanged(int from, int /*charsRemoved*/, i } if (!d->blockUpdate) - emit update(QRectF(0., -doc->documentMargin(), 1000000000., 1000000000.)); // optimization potential + emit update(QRectF(0., -doc->documentMargin(), 1000000000., 1000000000.)); // optimization potential } @@ -639,9 +639,10 @@ void QPlainTextEditPrivate::setTopBlock(int blockNumber, int lineNumber, int dx) lineNumber = maxTopLine - block.firstLineNumber(); } - bool vbarSignalsBlocked = vbar->blockSignals(true); - vbar->setValue(newTopLine); - vbar->blockSignals(vbarSignalsBlocked); + { + const QSignalBlocker blocker(vbar); + vbar->setValue(newTopLine); + } if (!dx && blockNumber == control->topBlock && lineNumber == topLine) return; @@ -657,9 +658,10 @@ void QPlainTextEditPrivate::setTopBlock(int blockNumber, int lineNumber, int dx) control->topBlock = blockNumber; topLine = lineNumber; - bool vbarSignalsBlocked = vbar->blockSignals(true); - vbar->setValue(block.firstLineNumber() + lineNumber); - vbar->blockSignals(vbarSignalsBlocked); + { + const QSignalBlocker blocker(vbar); + vbar->setValue(block.firstLineNumber() + lineNumber); + } if (dx || dy) { viewport->scroll(q->isRightToLeft() ? -dx : dx, dy); @@ -1006,9 +1008,11 @@ void QPlainTextEditPrivate::_q_adjustScrollbars() QTextBlock firstVisibleBlock = q->firstVisibleBlock(); if (firstVisibleBlock.isValid()) visualTopLine = firstVisibleBlock.firstLineNumber() + topLine; - bool vbarSignalsBlocked = vbar->blockSignals(true); - vbar->setValue(visualTopLine); - vbar->blockSignals(vbarSignalsBlocked); + + { + const QSignalBlocker blocker(vbar); + vbar->setValue(visualTopLine); + } hbar->setRange(0, (int)documentSize.width() - viewport->width()); hbar->setPageStep(viewport->width()); diff --git a/src/widgets/widgets/qpushbutton.cpp b/src/widgets/widgets/qpushbutton.cpp index a10d726e36..264123abf0 100644 --- a/src/widgets/widgets/qpushbutton.cpp +++ b/src/widgets/widgets/qpushbutton.cpp @@ -647,7 +647,7 @@ void QPushButton::setFlat(bool flat) if (d->flat == flat) return; d->flat = flat; - d->resetLayoutItemMargins(); + d->resetLayoutItemMargins(); d->sizeHint = QSize(); update(); updateGeometry(); @@ -673,8 +673,8 @@ bool QPushButton::event(QEvent *e) || e->type() == QEvent::MacSizeChange #endif ) { - d->resetLayoutItemMargins(); - updateGeometry(); + d->resetLayoutItemMargins(); + updateGeometry(); } else if (e->type() == QEvent::PolishRequest) { updateGeometry(); } diff --git a/src/widgets/widgets/qsizegrip.cpp b/src/widgets/widgets/qsizegrip.cpp index 106a8d770a..e46de3958f 100644 --- a/src/widgets/widgets/qsizegrip.cpp +++ b/src/widgets/widgets/qsizegrip.cpp @@ -482,7 +482,7 @@ bool QSizeGrip::eventFilter(QObject *o, QEvent *e) Q_D(QSizeGrip); if ((isHidden() && testAttribute(Qt::WA_WState_ExplicitShowHide)) || e->type() != QEvent::WindowStateChange - || o != d->tlw) { + || o != d->tlw) { return QWidget::eventFilter(o, e); } Qt::WindowStates sizeGripNotVisibleState = Qt::WindowFullScreen; diff --git a/src/widgets/widgets/qslider.cpp b/src/widgets/widgets/qslider.cpp index 2d91cd07e6..0ff31af630 100644 --- a/src/widgets/widgets/qslider.cpp +++ b/src/widgets/widgets/qslider.cpp @@ -63,7 +63,7 @@ public: QSlider::TickPosition tickPosition; int clickOffset; void init(); - void resetLayoutItemMargins(); + void resetLayoutItemMargins(); int pixelPosToRangeValue(int pos) const; inline int pick(const QPoint &pt) const; @@ -86,7 +86,7 @@ void QSliderPrivate::init() sp.transpose(); q->setSizePolicy(sp); q->setAttribute(Qt::WA_WState_OwnSizePolicy, false); - resetLayoutItemMargins(); + resetLayoutItemMargins(); } void QSliderPrivate::resetLayoutItemMargins() diff --git a/src/widgets/widgets/qspinbox.cpp b/src/widgets/widgets/qspinbox.cpp index 2a34451408..e198dae168 100644 --- a/src/widgets/widgets/qspinbox.cpp +++ b/src/widgets/widgets/qspinbox.cpp @@ -463,8 +463,8 @@ void QSpinBox::setDisplayIntegerBase(int base) display the given \a value. The default implementation returns a string containing \a value printed in the standard way using QWidget::locale().toString(), but with the thousand separator - removed. Reimplementations may return anything. (See the example - in the detailed description.) + removed unless setGroupSeparatorShown() is set. Reimplementations may + return anything. (See the example in the detailed description.) Note: QSpinBox does not call this function for specialValueText() and that neither prefix() nor suffix() should be included in the @@ -487,7 +487,7 @@ QString QSpinBox::textFromValue(int value) const str.prepend('-'); } else { str = locale().toString(value); - if (qAbs(value) >= 1000 || value == INT_MIN) { + if (!d->showGroupSeparator && (qAbs(value) >= 1000 || value == INT_MIN)) { str.remove(locale().groupSeparator()); } } @@ -538,7 +538,8 @@ QValidator::State QSpinBox::validate(QString &text, int &pos) const */ void QSpinBox::fixup(QString &input) const { - input.remove(locale().groupSeparator()); + if (!isGroupSeparatorShown()) + input.remove(locale().groupSeparator()); } @@ -891,7 +892,8 @@ void QDoubleSpinBox::setDecimals(int decimals) display the given \a value. The default implementation returns a string containing \a value printed using QWidget::locale().toString(\a value, QLatin1Char('f'), decimals()) and will remove the thousand - separator. Reimplementations may return anything. + separator unless setGroupSeparatorShown() is set. Reimplementations may + return anything. Note: QDoubleSpinBox does not call this function for specialValueText() and that neither prefix() nor suffix() should @@ -908,9 +910,9 @@ QString QDoubleSpinBox::textFromValue(double value) const { Q_D(const QDoubleSpinBox); QString str = locale().toString(value, 'f', d->decimals); - if (qAbs(value) >= 1000.0) { + if (!d->showGroupSeparator && qAbs(value) >= 1000.0) str.remove(locale().groupSeparator()); - } + return str; } diff --git a/src/widgets/widgets/qsplashscreen.cpp b/src/widgets/widgets/qsplashscreen.cpp index b2a0d3f8b8..db9db68039 100644 --- a/src/widgets/widgets/qsplashscreen.cpp +++ b/src/widgets/widgets/qsplashscreen.cpp @@ -251,7 +251,9 @@ inline static bool waitForWindowExposed(QWindow *window, int timeout = 1000) break; QCoreApplication::processEvents(QEventLoop::AllEvents, remaining); QCoreApplication::sendPostedEvents(0, QEvent::DeferredDelete); -#ifdef Q_OS_WIN +#if defined(Q_OS_WINRT) + WaitForSingleObjectEx(GetCurrentThread(), TimeOutMs, false); +#elif defined(Q_OS_WIN) Sleep(uint(TimeOutMs)); #else struct timespec ts = { TimeOutMs / 1000, (TimeOutMs % 1000) * 1000 * 1000 }; diff --git a/src/widgets/widgets/qtabwidget.cpp b/src/widgets/widgets/qtabwidget.cpp index 8c15b3e58e..fced1c01ec 100644 --- a/src/widgets/widgets/qtabwidget.cpp +++ b/src/widgets/widgets/qtabwidget.cpp @@ -759,11 +759,10 @@ void QTabWidgetPrivate::_q_removeTab(int index) void QTabWidgetPrivate::_q_tabMoved(int from, int to) { - stack->blockSignals(true); + const QSignalBlocker blocker(stack); QWidget *w = stack->widget(from); stack->removeWidget(w); stack->insertWidget(to, w); - stack->blockSignals(false); } /* diff --git a/src/widgets/widgets/qtextbrowser.cpp b/src/widgets/widgets/qtextbrowser.cpp index 273a5dabeb..9ecc87aac4 100644 --- a/src/widgets/widgets/qtextbrowser.cpp +++ b/src/widgets/widgets/qtextbrowser.cpp @@ -296,7 +296,7 @@ void QTextBrowserPrivate::setSource(const QUrl &url) QTextCodec *codec = Qt::codecForHtml(ba); txt = codec->toUnicode(ba); #else - txt = data.toString(); + txt = data.toString(); #endif } if (txt.isEmpty()) diff --git a/src/widgets/widgets/qtoolbar.cpp b/src/widgets/widgets/qtoolbar.cpp index 5e7eb943ab..d20b7a380d 100644 --- a/src/widgets/widgets/qtoolbar.cpp +++ b/src/widgets/widgets/qtoolbar.cpp @@ -650,9 +650,9 @@ void QToolBar::setOrientation(Qt::Orientation orientation) d->orientation = orientation; if (orientation == Qt::Vertical) - setSizePolicy(QSizePolicy(QSizePolicy::Fixed, QSizePolicy::Preferred)); + setSizePolicy(QSizePolicy(QSizePolicy::Fixed, QSizePolicy::Preferred)); else - setSizePolicy(QSizePolicy(QSizePolicy::Preferred, QSizePolicy::Fixed)); + setSizePolicy(QSizePolicy(QSizePolicy::Preferred, QSizePolicy::Fixed)); d->layout->invalidate(); d->layout->activate(); diff --git a/src/widgets/widgets/qtoolbar.h b/src/widgets/widgets/qtoolbar.h index 663497493f..fbe509f522 100644 --- a/src/widgets/widgets/qtoolbar.h +++ b/src/widgets/widgets/qtoolbar.h @@ -105,7 +105,7 @@ public: QAction *addAction(const QIcon &icon, const QString &text); QAction *addAction(const QString &text, const QObject *receiver, const char* member); QAction *addAction(const QIcon &icon, const QString &text, - const QObject *receiver, const char* member); + const QObject *receiver, const char* member); QAction *addSeparator(); QAction *insertSeparator(QAction *before); diff --git a/src/widgets/widgets/qtoolbararealayout.cpp b/src/widgets/widgets/qtoolbararealayout.cpp index 04ef6a80be..afb4244d0c 100644 --- a/src/widgets/widgets/qtoolbararealayout.cpp +++ b/src/widgets/widgets/qtoolbararealayout.cpp @@ -1307,8 +1307,8 @@ bool QToolBarAreaLayout::restoreState(QDataStream &stream, const QList<QToolBar* QList<QToolBar*> toolBars = _toolBars; int lines; stream >> lines; - if (!testing) - testing = mainWindow->unifiedTitleAndToolBarOnMac(); + if (!testing) + testing = mainWindow->unifiedTitleAndToolBarOnMac(); for (int j = 0; j < lines; ++j) { int pos; @@ -1319,7 +1319,7 @@ bool QToolBarAreaLayout::restoreState(QDataStream &stream, const QList<QToolBar* stream >> cnt; QToolBarAreaLayoutInfo &dock = docks[pos]; - const bool applyingLayout = !testing && !(pos == QInternal::TopDock && mainWindow->unifiedTitleAndToolBarOnMac()); + const bool applyingLayout = !testing && !(pos == QInternal::TopDock && mainWindow->unifiedTitleAndToolBarOnMac()); QToolBarAreaLayoutLine line(dock.o); for (int k = 0; k < cnt; ++k) { diff --git a/src/widgets/widgets/qwidgettextcontrol.cpp b/src/widgets/widgets/qwidgettextcontrol.cpp index b8f8762240..9112e738da 100644 --- a/src/widgets/widgets/qwidgettextcontrol.cpp +++ b/src/widgets/widgets/qwidgettextcontrol.cpp @@ -3126,7 +3126,7 @@ QRectF QWidgetTextControl::blockBoundingRect(const QTextBlock &block) const } #ifndef QT_NO_CONTEXTMENU -#define NUM_CONTROL_CHARACTERS 10 +#define NUM_CONTROL_CHARACTERS 14 const struct QUnicodeControlCharacter { const char *text; ushort character; @@ -3141,6 +3141,10 @@ const struct QUnicodeControlCharacter { { QT_TRANSLATE_NOOP("QUnicodeControlCharacterMenu", "LRO Start of left-to-right override"), 0x202d }, { QT_TRANSLATE_NOOP("QUnicodeControlCharacterMenu", "RLO Start of right-to-left override"), 0x202e }, { QT_TRANSLATE_NOOP("QUnicodeControlCharacterMenu", "PDF Pop directional formatting"), 0x202c }, + { QT_TRANSLATE_NOOP("QUnicodeControlCharacterMenu", "LRI Left-to-right isolate"), 0x2066 }, + { QT_TRANSLATE_NOOP("QUnicodeControlCharacterMenu", "RLI Right-to-left isolate"), 0x2067 }, + { QT_TRANSLATE_NOOP("QUnicodeControlCharacterMenu", "FSI First strong isolate"), 0x2068 }, + { QT_TRANSLATE_NOOP("QUnicodeControlCharacterMenu", "PDI Pop directional isolate"), 0x2069 } }; QUnicodeControlCharacterMenu::QUnicodeControlCharacterMenu(QObject *_editWidget, QWidget *parent) |