diff --git a/src/corelib/global/qnamespace.h b/src/corelib/global/qnamespace.h index 7f8c70f78e9..a37b87546a6 100644 --- a/src/corelib/global/qnamespace.h +++ b/src/corelib/global/qnamespace.h @@ -240,6 +240,7 @@ namespace Qt { "Use Qt::ExpandedClientAreaHint instead") = 0x00400000, #endif ExpandedClientAreaHint = 0x00400000, + NoTitleBarBackgroundHint = 0x00800000, CustomizeWindowHint = 0x02000000, WindowStaysOnBottomHint = 0x04000000, diff --git a/src/corelib/global/qnamespace.qdoc b/src/corelib/global/qnamespace.qdoc index 5a0abb22624..2793fdce4c3 100644 --- a/src/corelib/global/qnamespace.qdoc +++ b/src/corelib/global/qnamespace.qdoc @@ -2353,6 +2353,11 @@ window's \l{QWindow::safeAreaMargins()}{safe area margins} will reflect any areas that may have conflicting UI elements. + \value [since 6.9] NoTitleBarBackgroundHint Requests that the window's title bar is drawn + without a background color. This flag is useful in combination with + Qt::ExpandedClientAreaHint, to give the perception that the window's + client area seamlessly blends with the titlebar area and controls. + \value WindowType_Mask A mask for extracting the window type part of the window flags. diff --git a/src/plugins/platforms/cocoa/qcocoawindow.mm b/src/plugins/platforms/cocoa/qcocoawindow.mm index 68c4ccce959..8904570e558 100644 --- a/src/plugins/platforms/cocoa/qcocoawindow.mm +++ b/src/plugins/platforms/cocoa/qcocoawindow.mm @@ -744,6 +744,9 @@ void QCocoaWindow::setWindowFlags(Qt::WindowFlags flags) bool ignoreMouse = flags & Qt::WindowTransparentForInput; if (m_view.window.ignoresMouseEvents != ignoreMouse) m_view.window.ignoresMouseEvents = ignoreMouse; + + m_view.window.titlebarAppearsTransparent = (flags & Qt::NoTitleBarBackgroundHint) + || (m_view.window.styleMask & QT_IGNORE_DEPRECATIONS(NSWindowStyleMaskTexturedBackground)); } // ----------------------- Window state ----------------------- @@ -2034,7 +2037,6 @@ void QCocoaWindow::applyContentBorderThickness(NSWindow *window) if (!m_drawContentBorderGradient) { window.styleMask = window.styleMask & ~NSWindowStyleMaskTexturedBackground; [window.contentView.superview setNeedsDisplay:YES]; - window.titlebarAppearsTransparent = NO; return; } @@ -2059,7 +2061,6 @@ void QCocoaWindow::applyContentBorderThickness(NSWindow *window) int effectiveBottomContentBorderThickness = 0; [window setStyleMask:[window styleMask] | NSWindowStyleMaskTexturedBackground]; - window.titlebarAppearsTransparent = YES; // Setting titlebarAppearsTransparent to YES means that the border thickness has to account // for the title bar height as well, otherwise sheets will not be presented at the correct diff --git a/tests/manual/windowflags/controls.cpp b/tests/manual/windowflags/controls.cpp index dd96eea5069..99b9fcb8f09 100644 --- a/tests/manual/windowflags/controls.cpp +++ b/tests/manual/windowflags/controls.cpp @@ -33,6 +33,7 @@ HintControl::HintControl(QWidget *parent) , transparentForInputCheckBox(new QCheckBox(tr("Transparent for input"))) , noDropShadowCheckBox(new QCheckBox(tr("No drop shadow"))) , expandedClientAreaCheckBox(new QCheckBox(tr("Expanded client area"))) + , noTitleBarBackgroundCheckBox(new QCheckBox(tr("No titlebar background"))) { connect(msWindowsFixedSizeDialogCheckBox, SIGNAL(clicked()), this, SLOT(slotCheckBoxChanged())); connect(x11BypassWindowManagerCheckBox, SIGNAL(clicked()), this, SLOT(slotCheckBoxChanged())); @@ -51,6 +52,7 @@ HintControl::HintControl(QWidget *parent) connect(transparentForInputCheckBox, SIGNAL(clicked()), this, SLOT(slotCheckBoxChanged())); connect(noDropShadowCheckBox, SIGNAL(clicked()), this, SLOT(slotCheckBoxChanged())); connect(expandedClientAreaCheckBox, SIGNAL(clicked()), this, SLOT(slotCheckBoxChanged())); + connect(noTitleBarBackgroundCheckBox, SIGNAL(clicked()), this, SLOT(slotCheckBoxChanged())); auto *layout = new QHBoxLayout(this); layout->setSpacing(0); @@ -70,6 +72,7 @@ HintControl::HintControl(QWidget *parent) basicHintsLayout->addWidget(msWindowsFixedSizeDialogCheckBox); basicHintsLayout->addWidget(x11BypassWindowManagerCheckBox); basicHintsLayout->addWidget(expandedClientAreaCheckBox); + basicHintsLayout->addWidget(noTitleBarBackgroundCheckBox); layout->addLayout(basicHintsLayout); customizeWindowGroup->setCheckable(true); @@ -128,6 +131,8 @@ Qt::WindowFlags HintControl::hints() const flags |= Qt::NoDropShadowWindowHint; if (expandedClientAreaCheckBox->isChecked()) flags |= Qt::ExpandedClientAreaHint; + if (noTitleBarBackgroundCheckBox->isChecked()) + flags |= Qt::NoTitleBarBackgroundHint; return flags; } @@ -150,6 +155,7 @@ void HintControl::setHints(Qt::WindowFlags flags) transparentForInputCheckBox->setChecked(flags & Qt::WindowTransparentForInput); noDropShadowCheckBox->setChecked(flags & Qt::NoDropShadowWindowHint); expandedClientAreaCheckBox->setChecked(flags & Qt::ExpandedClientAreaHint); + noTitleBarBackgroundCheckBox->setChecked(flags & Qt::NoTitleBarBackgroundHint); } void HintControl::slotCheckBoxChanged() diff --git a/tests/manual/windowflags/controls.h b/tests/manual/windowflags/controls.h index 04b5f48adda..b2c015f9d67 100644 --- a/tests/manual/windowflags/controls.h +++ b/tests/manual/windowflags/controls.h @@ -48,6 +48,7 @@ private: QCheckBox *transparentForInputCheckBox; QCheckBox *noDropShadowCheckBox; QCheckBox *expandedClientAreaCheckBox; + QCheckBox *noTitleBarBackgroundCheckBox; }; // Control for the Qt::WindowState enum, optional with a "visible" QCheckbox