summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTor Arne Vestbø <[email protected]>2024-11-12 14:35:17 +0100
committerTor Arne Vestbø <[email protected]>2024-11-25 19:38:23 +0000
commita1e6fed44964a3eb14045bf819d232d6cbad9f59 (patch)
tree96f70b4f14099a9a798367a3218dce31eaab45cf
parentebb2658242e4c088099de8b3bc04c1e2af579bdc (diff)
Add Qt::NoTitleBarBackgroundHint window flag
The flag requests that the window's title bar is drawn without a background color. This flag is useful in combination with the Qt::ExpandedClientAreaHint flag, to give the perception that the window's client area seamlessly blends with the titlebar area and controls. Task-number: QTBUG-127634 Change-Id: I1194630d737ae03324f79d2babd7ea3d8fca3d5b Reviewed-by: Assam Boudjelthia <[email protected]>
-rw-r--r--src/corelib/global/qnamespace.h1
-rw-r--r--src/corelib/global/qnamespace.qdoc5
-rw-r--r--src/plugins/platforms/cocoa/qcocoawindow.mm5
-rw-r--r--tests/manual/windowflags/controls.cpp6
-rw-r--r--tests/manual/windowflags/controls.h1
5 files changed, 16 insertions, 2 deletions
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