Use QFlags::setFlag where prudent in qtbase

QFlags::setFlag is most useful to replace explicit constructs like

if (condition) {
   someFlags |= TheConditionFlag;
} else {
   someFlags &= ~TheConditionFlag;
}

with

someFlags.setFlag(TheConditionFlag, condition);

Change-Id: Ie4586681c83e0af812d5bbf14965aad51941a960
Reviewed-by: Marc Mutz <marc.mutz@kdab.com>
This commit is contained in:
Andre Somers 2016-02-02 14:40:29 +01:00 committed by Andre Somers
parent c5d4972577
commit 0df5c366e5
25 changed files with 54 additions and 185 deletions

View File

@ -3130,10 +3130,7 @@ void QTextStream::setGenerateByteOrderMark(bool generate)
{ {
Q_D(QTextStream); Q_D(QTextStream);
if (d->writeBuffer.isEmpty()) { if (d->writeBuffer.isEmpty()) {
if (generate) d->writeConverterState.flags.setFlag(QTextCodec::IgnoreHeader, !generate);
d->writeConverterState.flags &= ~QTextCodec::IgnoreHeader;
else
d->writeConverterState.flags |= QTextCodec::IgnoreHeader;
} }
} }

View File

@ -282,11 +282,8 @@ QSurfaceFormat::~QSurfaceFormat()
void QSurfaceFormat::setStereo(bool enable) void QSurfaceFormat::setStereo(bool enable)
{ {
QSurfaceFormat::FormatOptions newOptions = d->opts; QSurfaceFormat::FormatOptions newOptions = d->opts;
if (enable) { newOptions.setFlag(QSurfaceFormat::StereoBuffers, enable);
newOptions |= QSurfaceFormat::StereoBuffers;
} else {
newOptions &= ~QSurfaceFormat::StereoBuffers;
}
if (int(newOptions) != int(d->opts)) { if (int(newOptions) != int(d->opts)) {
detach(); detach();
d->opts = newOptions; d->opts = newOptions;

View File

@ -414,10 +414,7 @@ void QGlyphRun::setFlag(GlyphRunFlag flag, bool enabled)
return; return;
detach(); detach();
if (enabled) d->flags.setFlag(flag, enabled);
d->flags |= flag;
else
d->flags &= ~flag;
} }
/*! /*!

View File

@ -664,10 +664,7 @@ QList<QSslCertificate> QSslConfiguration::systemCaCertificates()
*/ */
void QSslConfiguration::setSslOption(QSsl::SslOption option, bool on) void QSslConfiguration::setSslOption(QSsl::SslOption option, bool on)
{ {
if (on) d->sslOptions.setFlag(option, on);
d->sslOptions |= option;
else
d->sslOptions &= ~option;
} }
/*! /*!

View File

@ -5553,10 +5553,7 @@ QSize QGLTexture::bindCompressedTexturePVR(const char *buf, int len)
// Set the invert flag for the texture. The "vertical flip" // Set the invert flag for the texture. The "vertical flip"
// flag in PVR is the opposite sense to our sense of inversion. // flag in PVR is the opposite sense to our sense of inversion.
if ((pvrHeader->flags & PVR_VERTICAL_FLIP) != 0) options.setFlag(QGLContext::InvertedYBindOption, !(pvrHeader->flags & PVR_VERTICAL_FLIP));
options &= ~QGLContext::InvertedYBindOption;
else
options |= QGLContext::InvertedYBindOption;
return QSize(pvrHeader->width, pvrHeader->height); return QSize(pvrHeader->width, pvrHeader->height);
} }

View File

@ -266,10 +266,7 @@ void QEvdevMouseHandler::readMouseData()
case 0x11e: button = Qt::ExtraButton12; break; case 0x11e: button = Qt::ExtraButton12; break;
case 0x11f: button = Qt::ExtraButton13; break; case 0x11f: button = Qt::ExtraButton13; break;
} }
if (data->value) m_buttons.setFlag(button, data->value);
m_buttons |= button;
else
m_buttons &= ~button;
btnChanged = true; btnChanged = true;
} else if (data->type == EV_SYN && data->code == SYN_REPORT) { } else if (data->type == EV_SYN && data->code == SYN_REPORT) {
if (btnChanged) { if (btnChanged) {

View File

@ -76,10 +76,7 @@ void QLibInputPointer::processButton(libinput_event_pointer *e)
case 0x11f: button = Qt::ExtraButton13; break; case 0x11f: button = Qt::ExtraButton13; break;
} }
if (pressed) m_buttons.setFlag(button, pressed);
m_buttons |= button;
else
m_buttons &= ~button;
QWindowSystemInterface::handleMouseEvent(Q_NULLPTR, m_pos, m_pos, m_buttons, QGuiApplication::keyboardModifiers()); QWindowSystemInterface::handleMouseEvent(Q_NULLPTR, m_pos, m_pos, m_buttons, QGuiApplication::keyboardModifiers());
} }

View File

@ -472,7 +472,7 @@ public:
xcb_window_t getSelectionOwner(xcb_atom_t atom) const; xcb_window_t getSelectionOwner(xcb_atom_t atom) const;
xcb_window_t getQtSelectionOwner(); xcb_window_t getQtSelectionOwner();
void setButton(Qt::MouseButton button, bool down) { if (down) m_buttons |= button; else m_buttons &= ~button; } void setButton(Qt::MouseButton button, bool down) { m_buttons.setFlag(button, down); }
Qt::MouseButtons buttons() const { return m_buttons; } Qt::MouseButtons buttons() const { return m_buttons; }
Qt::MouseButton translateMouseButton(xcb_button_t s); Qt::MouseButton translateMouseButton(xcb_button_t s);

View File

@ -786,10 +786,8 @@ void QFileDialog::setOptions(Options options)
if (changed & DontUseCustomDirectoryIcons) { if (changed & DontUseCustomDirectoryIcons) {
QFileIconProvider::Options providerOptions = iconProvider()->options(); QFileIconProvider::Options providerOptions = iconProvider()->options();
if (options & DontUseCustomDirectoryIcons) providerOptions.setFlag(QFileIconProvider::DontUseCustomDirectoryIcons,
providerOptions |= QFileIconProvider::DontUseCustomDirectoryIcons; options & DontUseCustomDirectoryIcons);
else
providerOptions &= ~QFileIconProvider::DontUseCustomDirectoryIcons;
iconProvider()->setOptions(providerOptions); iconProvider()->setOptions(providerOptions);
} }
} }
@ -3717,10 +3715,7 @@ void QFileDialogPrivate::_q_showHidden()
{ {
Q_Q(QFileDialog); Q_Q(QFileDialog);
QDir::Filters dirFilters = q->filter(); QDir::Filters dirFilters = q->filter();
if (showHiddenAction->isChecked()) dirFilters.setFlag(QDir::Hidden, showHiddenAction->isChecked());
dirFilters |= QDir::Hidden;
else
dirFilters &= ~QDir::Hidden;
q->setFilter(dirFilters); q->setFilter(dirFilters);
} }

View File

@ -1297,10 +1297,7 @@ void QGraphicsView::setRenderHint(QPainter::RenderHint hint, bool enabled)
{ {
Q_D(QGraphicsView); Q_D(QGraphicsView);
QPainter::RenderHints oldHints = d->renderHints; QPainter::RenderHints oldHints = d->renderHints;
if (enabled) d->renderHints.setFlag(hint, enabled);
d->renderHints |= hint;
else
d->renderHints &= ~hint;
if (oldHints != d->renderHints) if (oldHints != d->renderHints)
d->updateAll(); d->updateAll();
} }
@ -1463,10 +1460,7 @@ void QGraphicsView::setOptimizationFlags(OptimizationFlags flags)
void QGraphicsView::setOptimizationFlag(OptimizationFlag flag, bool enabled) void QGraphicsView::setOptimizationFlag(OptimizationFlag flag, bool enabled)
{ {
Q_D(QGraphicsView); Q_D(QGraphicsView);
if (enabled) d->optimizationFlags.setFlag(flag, enabled);
d->optimizationFlags |= flag;
else
d->optimizationFlags &= ~flag;
} }
/*! /*!

View File

@ -2272,15 +2272,8 @@ void QGraphicsWidget::paintWindowFrame(QPainter *painter, const QStyleOptionGrap
bar.QStyleOption::operator=(*option); bar.QStyleOption::operator=(*option);
d->initStyleOptionTitleBar(&bar); // this clear flags in bar.state d->initStyleOptionTitleBar(&bar); // this clear flags in bar.state
d->ensureWindowData(); d->ensureWindowData();
if (d->windowData->buttonMouseOver) bar.state.setFlag(QStyle::State_MouseOver, d->windowData->buttonMouseOver);
bar.state |= QStyle::State_MouseOver; bar.state.setFlag(QStyle::State_Sunken, d->windowData->buttonSunken);
else
bar.state &= ~QStyle::State_MouseOver;
if (d->windowData->buttonSunken)
bar.state |= QStyle::State_Sunken;
else
bar.state &= ~QStyle::State_Sunken;
bar.rect = windowFrameRect; bar.rect = windowFrameRect;
// translate painter to make the style happy // translate painter to make the style happy
@ -2337,17 +2330,9 @@ void QGraphicsWidget::paintWindowFrame(QPainter *painter, const QStyleOptionGrap
initStyleOption(&frameOptions); initStyleOption(&frameOptions);
if (!hasBorder) if (!hasBorder)
painter->setClipRect(windowFrameRect.adjusted(0, +height, 0, 0), Qt::IntersectClip); painter->setClipRect(windowFrameRect.adjusted(0, +height, 0, 0), Qt::IntersectClip);
if (hasFocus()) { frameOptions.state.setFlag(QStyle::State_HasFocus, hasFocus());
frameOptions.state |= QStyle::State_HasFocus;
} else {
frameOptions.state &= ~QStyle::State_HasFocus;
}
bool isActive = isActiveWindow(); bool isActive = isActiveWindow();
if (isActive) { frameOptions.state.setFlag(QStyle::State_Active, isActive);
frameOptions.state |= QStyle::State_Active;
} else {
frameOptions.state &= ~QStyle::State_Active;
}
frameOptions.palette.setCurrentColorGroup(isActive ? QPalette::Active : QPalette::Normal); frameOptions.palette.setCurrentColorGroup(isActive ? QPalette::Active : QPalette::Normal);
frameOptions.rect = windowFrameRect; frameOptions.rect = windowFrameRect;

View File

@ -327,12 +327,11 @@ void QGraphicsWidgetPrivate::initStyleOptionTitleBar(QStyleOptionTitleBar *optio
option->subControls = QStyle::SC_TitleBarCloseButton | QStyle::SC_TitleBarLabel | QStyle::SC_TitleBarSysMenu; option->subControls = QStyle::SC_TitleBarCloseButton | QStyle::SC_TitleBarLabel | QStyle::SC_TitleBarSysMenu;
option->activeSubControls = windowData->hoveredSubControl; option->activeSubControls = windowData->hoveredSubControl;
bool isActive = q->isActiveWindow(); bool isActive = q->isActiveWindow();
option->state.setFlag(QStyle::State_Active, isActive);
if (isActive) { if (isActive) {
option->state |= QStyle::State_Active;
option->titleBarState = Qt::WindowActive; option->titleBarState = Qt::WindowActive;
option->titleBarState |= QStyle::State_Active; option->titleBarState |= QStyle::State_Active;
} else { } else {
option->state &= ~QStyle::State_Active;
option->titleBarState = Qt::WindowNoState; option->titleBarState = Qt::WindowNoState;
} }
QFont windowTitleFont = QApplication::font("QMdiSubWindowTitleBar"); QFont windowTitleFont = QApplication::font("QMdiSubWindowTitleBar");

View File

@ -1015,10 +1015,7 @@ void QListView::paintEvent(QPaintEvent *e)
if (viewState == EditingState) if (viewState == EditingState)
option.state |= QStyle::State_Editing; option.state |= QStyle::State_Editing;
} }
if (*it == hover) option.state.setFlag(QStyle::State_MouseOver, *it == hover);
option.state |= QStyle::State_MouseOver;
else
option.state &= ~QStyle::State_MouseOver;
if (alternate) { if (alternate) {
int row = (*it).row(); int row = (*it).row();
@ -1033,11 +1030,7 @@ void QListView::paintEvent(QPaintEvent *e)
alternateBase = (row & 1) != 0; alternateBase = (row & 1) != 0;
} }
} }
if (alternateBase) { option.features.setFlag(QStyleOptionViewItem::Alternate, alternateBase);
option.features |= QStyleOptionViewItem::Alternate;
} else {
option.features &= ~QStyleOptionViewItem::Alternate;
}
// draw background of the item (only alternate row). rest of the background // draw background of the item (only alternate row). rest of the background
// is provided by the delegate // is provided by the delegate

View File

@ -824,10 +824,7 @@ void QTableViewPrivate::drawAndClipSpans(const QRegion &area, QPainter *painter,
QStyleOptionViewItem opt = option; QStyleOptionViewItem opt = option;
opt.rect = rect; opt.rect = rect;
alternateBase = alternatingColors && (span->top() & 1); alternateBase = alternatingColors && (span->top() & 1);
if (alternateBase) opt.features.setFlag(QStyleOptionViewItem::Alternate, alternateBase);
opt.features |= QStyleOptionViewItem::Alternate;
else
opt.features &= ~QStyleOptionViewItem::Alternate;
drawCell(painter, opt, index); drawCell(painter, opt, index);
region -= rect; region -= rect;
for (int r = span->top(); r <= span->bottom(); ++r) { for (int r = span->top(); r <= span->bottom(); ++r) {

View File

@ -1359,11 +1359,7 @@ void QTreeViewPrivate::paintAlternatingRowColors(QPainter *painter, QStyleOption
} }
while (y <= bottom) { while (y <= bottom) {
option->rect.setRect(0, y, viewport->width(), rowHeight); option->rect.setRect(0, y, viewport->width(), rowHeight);
if (current & 1) { option->features.setFlag(QStyleOptionViewItem::Alternate, current & 1);
option->features |= QStyleOptionViewItem::Alternate;
} else {
option->features &= ~QStyleOptionViewItem::Alternate;
}
++current; ++current;
q->style()->drawPrimitive(QStyle::PE_PanelItemViewRow, option, painter, q); q->style()->drawPrimitive(QStyle::PE_PanelItemViewRow, option, painter, q);
y += rowHeight; y += rowHeight;
@ -1709,11 +1705,9 @@ void QTreeView::drawRow(QPainter *painter, const QStyleOptionViewItem &option,
else else
opt.state |= QStyle::State_HasFocus; opt.state |= QStyle::State_HasFocus;
} }
if ((hoverRow || modelIndex == hover) opt.state.setFlag(QStyle::State_MouseOver,
&& (option.showDecorationSelected || (d->hoverBranch == -1))) (hoverRow || modelIndex == hover)
opt.state |= QStyle::State_MouseOver; && (option.showDecorationSelected || d->hoverBranch == -1));
else
opt.state &= ~QStyle::State_MouseOver;
if (enabled) { if (enabled) {
QPalette::ColorGroup cg; QPalette::ColorGroup cg;
@ -1729,11 +1723,7 @@ void QTreeView::drawRow(QPainter *painter, const QStyleOptionViewItem &option,
} }
if (alternate) { if (alternate) {
if (d->current & 1) { opt.features.setFlag(QStyleOptionViewItem::Alternate, d->current & 1);
opt.features |= QStyleOptionViewItem::Alternate;
} else {
opt.features &= ~QStyleOptionViewItem::Alternate;
}
} }
/* Prior to Qt 4.3, the background of the branch (in selected state and /* Prior to Qt 4.3, the background of the branch (in selected state and
@ -1832,11 +1822,7 @@ void QTreeView::drawBranches(QPainter *painter, const QRect &rect,
painter->setBrushOrigin(QPoint(0, verticalOffset())); painter->setBrushOrigin(QPoint(0, verticalOffset()));
if (d->alternatingColors) { if (d->alternatingColors) {
if (d->current & 1) { opt.features.setFlag(QStyleOptionViewItem::Alternate, d->current & 1);
opt.features |= QStyleOptionViewItem::Alternate;
} else {
opt.features &= ~QStyleOptionViewItem::Alternate;
}
} }
// When hovering over a row, pass State_Hover for painting the branch // When hovering over a row, pass State_Hover for painting the branch
@ -1862,10 +1848,8 @@ void QTreeView::drawBranches(QPainter *painter, const QRect &rect,
| (moreSiblings ? QStyle::State_Sibling : QStyle::State_None) | (moreSiblings ? QStyle::State_Sibling : QStyle::State_None)
| (children ? QStyle::State_Children : QStyle::State_None) | (children ? QStyle::State_Children : QStyle::State_None)
| (expanded ? QStyle::State_Open : QStyle::State_None); | (expanded ? QStyle::State_Open : QStyle::State_None);
if (hoverRow || item == d->hoverBranch) opt.state.setFlag(QStyle::State_MouseOver, hoverRow || item == d->hoverBranch);
opt.state |= QStyle::State_MouseOver;
else
opt.state &= ~QStyle::State_MouseOver;
style()->drawPrimitive(QStyle::PE_IndicatorBranch, &opt, painter, this); style()->drawPrimitive(QStyle::PE_IndicatorBranch, &opt, painter, this);
} }
// then go out level by level // then go out level by level
@ -1890,10 +1874,8 @@ void QTreeView::drawBranches(QPainter *painter, const QRect &rect,
} }
if (moreSiblings) if (moreSiblings)
opt.state |= QStyle::State_Sibling; opt.state |= QStyle::State_Sibling;
if (hoverRow || item == d->hoverBranch) opt.state.setFlag(QStyle::State_MouseOver, hoverRow || item == d->hoverBranch);
opt.state |= QStyle::State_MouseOver;
else
opt.state &= ~QStyle::State_MouseOver;
style()->drawPrimitive(QStyle::PE_IndicatorBranch, &opt, painter, this); style()->drawPrimitive(QStyle::PE_IndicatorBranch, &opt, painter, this);
current = ancestor; current = ancestor;
ancestor = current.parent(); ancestor = current.parent();

View File

@ -1233,30 +1233,21 @@ const QAndroidStyle::AndroidDrawable * QAndroidStyle::AndroidStateDrawable::best
int QAndroidStyle::AndroidStateDrawable::extractState(const QVariantMap &value) int QAndroidStyle::AndroidStateDrawable::extractState(const QVariantMap &value)
{ {
int state = QStyle::State_Enabled | QStyle::State_Active;; QStyle::State state = QStyle::State_Enabled | QStyle::State_Active;;
foreach (const QString &key, value.keys()) { foreach (const QString &key, value.keys()) {
bool val = value.value(key).toString() == QLatin1String("true"); bool val = value.value(key).toString() == QLatin1String("true");
if (key == QLatin1String("enabled")) { if (key == QLatin1String("enabled")) {
if (val) state.setFlag(QStyle::State_Enabled, val);
state |= QStyle::State_Enabled;
else
state &= ~QStyle::State_Enabled;
continue; continue;
} }
if (key == QLatin1String("window_focused")) { if (key == QLatin1String("window_focused")) {
if (val) state.setFlag(QStyle::State_Active, val);
state |= QStyle::State_Active;
else
state &= ~QStyle::State_Active;
continue; continue;
} }
if (key == QLatin1String("focused")) { if (key == QLatin1String("focused")) {
if (val) state.setFlag(QStyle::State_HasFocus, val);
state |= QStyle::State_HasFocus;
else
state &= ~QStyle::State_HasFocus;
continue; continue;
} }
@ -1271,18 +1262,12 @@ int QAndroidStyle::AndroidStateDrawable::extractState(const QVariantMap &value)
} }
if (key == QLatin1String("selected")) { if (key == QLatin1String("selected")) {
if (val) state.setFlag(QStyle::State_Selected, val);
state |= QStyle::State_Selected;
else
state &= ~QStyle::State_Selected;
continue; continue;
} }
if (key == QLatin1String("active")) { if (key == QLatin1String("active")) {
if (val) state.setFlag(QStyle::State_Active, val);
state |= QStyle::State_Active;
else
state &= ~QStyle::State_Active;
continue; continue;
} }
@ -1292,7 +1277,7 @@ int QAndroidStyle::AndroidStateDrawable::extractState(const QVariantMap &value)
if (key == QLatin1String("background") && val) if (key == QLatin1String("background") && val)
return -1; return -1;
} }
return state; return static_cast<int>(state);
} }
void QAndroidStyle::AndroidStateDrawable::setPaddingLeftToSizeWidth() void QAndroidStyle::AndroidStateDrawable::setPaddingLeftToSizeWidth()

View File

@ -684,10 +684,7 @@ void QFusionStyle::drawPrimitive(PrimitiveElement elem,
{ {
QStyleOption dockWidgetHandle = *option; QStyleOption dockWidgetHandle = *option;
bool horizontal = option->state & State_Horizontal; bool horizontal = option->state & State_Horizontal;
if (horizontal) dockWidgetHandle.state.setFlag(State_Horizontal, !horizontal);
dockWidgetHandle.state &= ~State_Horizontal;
else
dockWidgetHandle.state |= State_Horizontal;
proxy()->drawControl(CE_Splitter, &dockWidgetHandle, painter, widget); proxy()->drawControl(CE_Splitter, &dockWidgetHandle, painter, widget);
} }
break; break;

View File

@ -177,10 +177,7 @@ void QCheckBox::initStyleOption(QStyleOptionButton *option) const
else else
option->state |= d->checked ? QStyle::State_On : QStyle::State_Off; option->state |= d->checked ? QStyle::State_On : QStyle::State_Off;
if (testAttribute(Qt::WA_Hover) && underMouse()) { if (testAttribute(Qt::WA_Hover) && underMouse()) {
if (d->hovering) option->state.setFlag(QStyle::State_MouseOver, d->hovering);
option->state |= QStyle::State_MouseOver;
else
option->state &= ~QStyle::State_MouseOver;
} }
option->text = d->text; option->text = d->text;
option->icon = d->icon; option->icon = d->icon;

View File

@ -103,11 +103,7 @@ void QGroupBox::initStyleOption(QStyleOptionGroupBox *option) const
option->activeSubControls |= d->pressedControl; option->activeSubControls |= d->pressedControl;
option->subControls = QStyle::SC_GroupBoxFrame; option->subControls = QStyle::SC_GroupBoxFrame;
if (d->hover) option->state.setFlag(QStyle::State_MouseOver, d->hover);
option->state |= QStyle::State_MouseOver;
else
option->state &= ~QStyle::State_MouseOver;
if (d->flat) if (d->flat)
option->features |= QStyleOptionFrame::Flat; option->features |= QStyleOptionFrame::Flat;

View File

@ -568,16 +568,10 @@ void QLineEdit::setEchoMode(EchoMode mode)
if (mode == (EchoMode)d->control->echoMode()) if (mode == (EchoMode)d->control->echoMode())
return; return;
Qt::InputMethodHints imHints = inputMethodHints(); Qt::InputMethodHints imHints = inputMethodHints();
if (mode == Password || mode == NoEcho) { imHints.setFlag(Qt::ImhHiddenText, mode == Password || mode == NoEcho);
imHints |= Qt::ImhHiddenText; imHints.setFlag(Qt::ImhNoAutoUppercase, mode != Normal);
} else { imHints.setFlag(Qt::ImhNoPredictiveText, mode != Normal);
imHints &= ~Qt::ImhHiddenText; imHints.setFlag(Qt::ImhSensitiveData, mode != Normal);
}
if (mode != Normal) {
imHints |= (Qt::ImhNoAutoUppercase | Qt::ImhNoPredictiveText | Qt::ImhSensitiveData);
} else {
imHints &= ~(Qt::ImhNoAutoUppercase | Qt::ImhNoPredictiveText | Qt::ImhSensitiveData);
}
setInputMethodHints(imHints); setInputMethodHints(imHints);
d->control->setEchoMode(mode); d->control->setEchoMode(mode);
update(); update();

View File

@ -922,10 +922,7 @@ void QMainWindow::setAnimated(bool enabled)
Q_D(QMainWindow); Q_D(QMainWindow);
DockOptions opts = d->layout->dockOptions; DockOptions opts = d->layout->dockOptions;
if (enabled) opts.setFlag(AnimatedDocks, enabled);
opts |= AnimatedDocks;
else
opts &= ~AnimatedDocks;
d->layout->setDockOptions(opts); d->layout->setDockOptions(opts);
} }
@ -961,10 +958,7 @@ void QMainWindow::setDockNestingEnabled(bool enabled)
Q_D(QMainWindow); Q_D(QMainWindow);
DockOptions opts = d->layout->dockOptions; DockOptions opts = d->layout->dockOptions;
if (enabled) opts.setFlag(AllowNestedDocks, enabled);
opts |= AllowNestedDocks;
else
opts &= ~AllowNestedDocks;
d->layout->setDockOptions(opts); d->layout->setDockOptions(opts);
} }

View File

@ -375,10 +375,7 @@ void QDockWidgetGroupWindow::adjustFlags()
Qt::WindowFlags flags = oldFlags; Qt::WindowFlags flags = oldFlags;
if (nativeDeco) { if (nativeDeco) {
flags |= Qt::CustomizeWindowHint | Qt::WindowTitleHint; flags |= Qt::CustomizeWindowHint | Qt::WindowTitleHint;
if (top->features() & QDockWidget::DockWidgetClosable) flags.setFlag(Qt::WindowCloseButtonHint, top->features() & QDockWidget::DockWidgetClosable);
flags |= Qt::WindowCloseButtonHint;
else
flags &= ~Qt::WindowCloseButtonHint;
flags &= ~Qt::FramelessWindowHint; flags &= ~Qt::FramelessWindowHint;
} else { } else {
flags |= Qt::FramelessWindowHint; flags |= Qt::FramelessWindowHint;

View File

@ -2104,10 +2104,7 @@ void QMdiArea::setActivationOrder(WindowOrder order)
void QMdiArea::setOption(AreaOption option, bool on) void QMdiArea::setOption(AreaOption option, bool on)
{ {
Q_D(QMdiArea); Q_D(QMdiArea);
if (on && !(d->options & option)) d->options.setFlag(option, on);
d->options |= option;
else if (!on && (d->options & option))
d->options &= ~option;
} }
/*! /*!

View File

@ -575,10 +575,7 @@ void ControllerWidget::setControlVisible(QMdiSubWindowPrivate::WindowStateAction
if (subControl == QStyle::SC_None) if (subControl == QStyle::SC_None)
return; return;
if (visible && !(visibleControls & subControl)) visibleControls.setFlag(subControl, visible && !(visibleControls & subControl));
visibleControls |= subControl;
else if (!visible && (visibleControls & subControl))
visibleControls &= ~subControl;
} }
/* /*
@ -2417,10 +2414,7 @@ bool QMdiSubWindow::isShaded() const
void QMdiSubWindow::setOption(SubWindowOption option, bool on) void QMdiSubWindow::setOption(SubWindowOption option, bool on)
{ {
Q_D(QMdiSubWindow); Q_D(QMdiSubWindow);
if (on && !(d->options & option)) d->options.setFlag(option, on);
d->options |= option;
else if (!on && (d->options & option))
d->options &= ~option;
#ifndef QT_NO_RUBBERBAND #ifndef QT_NO_RUBBERBAND
if ((option & (RubberBandResize | RubberBandMove)) && !on && d->isInRubberBandMode) if ((option & (RubberBandResize | RubberBandMove)) && !on && d->isInRubberBandMode)
@ -3172,10 +3166,7 @@ void QMdiSubWindow::paintEvent(QPaintEvent *paintEvent)
QStyleOptionFrame frameOptions; QStyleOptionFrame frameOptions;
frameOptions.initFrom(this); frameOptions.initFrom(this);
frameOptions.lineWidth = style()->pixelMetric(QStyle::PM_MdiSubWindowFrameWidth, 0, this); frameOptions.lineWidth = style()->pixelMetric(QStyle::PM_MdiSubWindowFrameWidth, 0, this);
if (d->isActive) frameOptions.state.setFlag(QStyle::State_Active, d->isActive);
frameOptions.state |= QStyle::State_Active;
else
frameOptions.state &= ~QStyle::State_Active;
// ### Ensure that we do not require setting the cliprect for 4.4 // ### Ensure that we do not require setting the cliprect for 4.4
if (!isMinimized() && !d->hasBorder(d->cachedStyleOptions)) if (!isMinimized() && !d->hasBorder(d->cachedStyleOptions))

View File

@ -182,10 +182,7 @@ void QRadioButton::initStyleOption(QStyleOptionButton *option) const
option->state |= QStyle::State_Sunken; option->state |= QStyle::State_Sunken;
option->state |= (d->checked) ? QStyle::State_On : QStyle::State_Off; option->state |= (d->checked) ? QStyle::State_On : QStyle::State_Off;
if (testAttribute(Qt::WA_Hover) && underMouse()) { if (testAttribute(Qt::WA_Hover) && underMouse()) {
if (d->hovering) option->state.setFlag(QStyle::State_MouseOver, d->hovering);
option->state |= QStyle::State_MouseOver;
else
option->state &= ~QStyle::State_MouseOver;
} }
} }