feat: Improve countdown tooltip positioning for multi-screen scenarios#787
Merged
deepin-bot[bot] merged 1 commit intoDec 25, 2025
Conversation
- Enhanced the logic for positioning the countdown tooltip when the recording area spans multiple screens. The tooltip now appears centered on the relevant screen, improving visibility and user experience. - Added detailed comments in the code to clarify the positioning logic based on the toolbar's screen context. This update addresses potential confusion during screen recording across multiple displays. 优化了录制区域跨屏时倒计时提示框的定位逻辑。 bug: https://pms.uniontech.com/story-view-39101.html
deepin pr auto review我来对这段代码进行审查:
// 添加辅助函数判断是否跨屏
bool isAreaCrossScreen(const QRect& area, QScreen* screen) {
if (!screen) return true;
QRect screenGeom = screen->geometry();
return !screenGeom.contains(area);
}
// 在类中添加成员变量缓存计算结果
QScreen* m_cachedScreen = nullptr;
QRect m_cachedScreenRect;
void MainWindow::startCountdown() {
// ... 其他代码 ...
// 使用缓存的屏幕信息
if (!m_cachedScreen) {
m_cachedScreen = QGuiApplication::screenAt(recordRect.center());
}
bool isRecordAreaCrossScreen = isAreaCrossScreen(
QRect(static_cast<int>(recordRect.x() / m_pixelRatio),
static_cast<int>(recordRect.y() / m_pixelRatio),
static_cast<int>(recordRect.width() / m_pixelRatio),
static_cast<int>(recordRect.height() / m_pixelRatio)),
m_cachedScreen);
// ... 其他代码 ...
// 使用QRect的center()方法简化计算
if (!isRecordAreaCrossScreen) {
QPoint center = recordRect.center();
countdownX = center.x() / m_pixelRatio - countdownTooltip->width() / 2;
countdownY = center.y() / m_pixelRatio - countdownTooltip->height() / 2;
}
// 添加边界检查
countdownX = qBound(targetScreenRect.left(), countdownX,
targetScreenRect.right() - countdownTooltip->width());
countdownY = qBound(targetScreenRect.top(), countdownY,
targetScreenRect.bottom() - countdownTooltip->height());
countdownTooltip->move(countdownX, countdownY);
}这些改进可以提高代码的可维护性、性能和安全性,同时保持原有功能不变。 |
lzwind
approved these changes
Dec 25, 2025
|
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: dengzhongyuan365-dev, lzwind The full list of commands accepted by this bot can be found here. DetailsNeeds approval from an approver in each of these files:Approvers can indicate their approval by writing |
Member
Author
|
/forcemerge |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
feat: Improve countdown tooltip positioning for multi-screen scenarios
This update addresses potential confusion during screen recording across multiple displays.
优化了录制区域跨屏时倒计时提示框的定位逻辑。
bug: https://pms.uniontech.com/story-view-39101.html