Skip to content

Commit cd79055

Browse files
fix: Refine background rendering logic for toolbar in recording modes
Updated the background rendering conditions to ensure the toolbar blur effect is applied correctly in recording and scrolling screenshot modes, enhancing visual consistency across different function types. This change improves the user experience by maintaining the intended appearance of the toolbar during various capture scenarios.
1 parent e56845c commit cd79055

File tree

1 file changed

+23
-12
lines changed

1 file changed

+23
-12
lines changed

src/main_window.cpp

Lines changed: 23 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -4785,21 +4785,32 @@ void MainWindow::paintEvent(QPaintEvent *event)
47854785
painter.setRenderHint(QPainter::Antialiasing, true);
47864786

47874787
// 绘制背景图片,用于工具栏模糊效果
4788-
// 原条件只在截图模式和2D模式下绘制,导致录屏/滚动截图模式下工具栏模糊失效
4789-
if (status::shot == m_functionType || status::record == m_functionType || status::scrollshot == m_functionType || m_hasComposite == false) {
4790-
// qCDebug(dsrApp) << "function: " << __func__ << " ,line: " << __LINE__;
4788+
// Qt6+XCB: widget是逻辑大小(m_backgroundRect),pixmap是物理大小
4789+
QRect backgroundRect;
4790+
if (Utils::isQt6XcbEnv) {
4791+
backgroundRect = QRect(0, 0, m_backgroundRect.width(), m_backgroundRect.height());
4792+
} else {
4793+
backgroundRect = QRect(0, 0, rootWindowRect.width(), rootWindowRect.height());
4794+
}
4795+
4796+
if (status::shot == m_functionType || m_hasComposite == false) {
4797+
// 截图模式或2D模式:全屏绘制背景
47914798
painter.setRenderHint(QPainter::Antialiasing, true);
4792-
4793-
// Qt6+XCB: widget是逻辑大小(m_backgroundRect),pixmap是物理大小
4794-
QRect backgroundRect;
4795-
if (Utils::isQt6XcbEnv) {
4796-
backgroundRect = QRect(0, 0, m_backgroundRect.width(), m_backgroundRect.height());
4797-
} else {
4798-
backgroundRect = QRect(0, 0, rootWindowRect.width(), rootWindowRect.height());
4799-
}
4800-
48014799
m_backgroundPixmap.setDevicePixelRatio(m_pixelRatio);
48024800
painter.drawPixmap(backgroundRect, m_backgroundPixmap);
4801+
} else if (status::record == m_functionType || status::scrollshot == m_functionType) {
4802+
// 录屏/滚动截图模式:只在工具栏区域绘制背景
4803+
// 不全屏绘制,避免影响鼠标穿透
4804+
if (m_toolBar && m_toolBar->isVisible()) {
4805+
QRect toolBarRect = m_toolBar->geometry();
4806+
toolBarRect.adjust(-20, -20, 20, 20);
4807+
4808+
painter.setRenderHint(QPainter::Antialiasing, true);
4809+
m_backgroundPixmap.setDevicePixelRatio(m_pixelRatio);
4810+
painter.setClipRect(toolBarRect);
4811+
painter.drawPixmap(backgroundRect, m_backgroundPixmap);
4812+
painter.setClipping(false);
4813+
}
48034814
}
48044815

48054816

0 commit comments

Comments
 (0)