feat: add icon scaling with keyboard shortcuts#653
Conversation
Reviewer's GuideThis PR introduces interactive icon scaling by adding an animated iconScaleFactor property, keyboard shortcuts to adjust the scale within set bounds, and propagating the scale factor into the icon delegate to ensure consistent, centered scaling across all icons. Class diagram for updated icon scaling propertiesclassDiagram
class FullscreenFrame {
+iconScaleFactor: real
}
class IconItemDelegate {
+iconScaleFactor: real
}
FullscreenFrame "1" --> "*" IconItemDelegate : iconScaleFactor
File-Level Changes
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
20e648f to
c6eec9a
Compare
c6eec9a to
4d881b3
Compare
1. Added icon scaling functionality with Ctrl++/Ctrl+= to zoom in and Ctrl+- to zoom out 2. Implemented smooth scaling animation with 200ms duration and easing 3. Set scaling limits between 0.5x and 1.0x with 0.1x step increments 4. Updated IconItemDelegate to support iconScaleFactor property for consistent scaling 5. Added transformOrigin: Item.Center to maintain icon positioning during scaling feat: 添加图标缩放功能和键盘快捷键 1. 添加图标缩放功能,支持 Ctrl++/Ctrl+= 放大和 Ctrl+- 缩小 2. 实现平滑缩放动画,持续时间为200毫秒并带有缓动效果 3. 设置缩放限制在0.5倍到1.0倍之间,每次调整0.1倍 4. 更新IconItemDelegate以支持iconScaleFactor属性,确保缩放一致性 5. 添加transformOrigin: Item.Center以在缩放过程中保持图标定位 Pms: BUG-289529
4d881b3 to
840e7a1
Compare
deepin pr auto review代码审查意见总体评价这个代码变更实现了桌面图标缩放功能,允许用户通过快捷键调整全屏模式下应用图标的缩放比例。代码结构清晰,实现合理,但有一些可以改进的地方。 具体改进建议1. 代码质量
2. 代码性能
3. 代码安全
4. 功能完善
修改建议代码示例// desktopintegration.h 中添加常量定义
static constexpr qreal MIN_ICON_SCALE_FACTOR = 0.5;
static constexpr qreal MAX_ICON_SCALE_FACTOR = 1.0;
static constexpr qreal ICON_SCALE_FACTOR_STEP = 0.1;
// 改进后的 setIconScaleFactor 方法
void DesktopIntegration::setIconScaleFactor(qreal factor)
{
// 参数验证
if (factor < MIN_ICON_SCALE_FACTOR || factor > MAX_ICON_SCALE_FACTOR) {
qCWarning(logDesktopIntegration) << "Invalid icon scale factor:" << factor;
return;
}
if (qFuzzyCompare(m_iconScaleFactor, factor)) {
return;
}
m_iconScaleFactor = factor;
// 保存到 dconfig
QScopedPointer<DConfig> dconfig(DConfig::create("org.deepin.dde.shell", "org.deepin.ds.launchpad"));
if (dconfig->isValid()) {
dconfig->setValue("iconScaleFactor", factor);
qCInfo(logDesktopIntegration) << "Icon scale factor saved:" << factor;
}
emit iconScaleFactorChanged();
}// FullscreenFrame.qml 中抽取的通用方法
function adjustIconScale(increase) {
var newValue = increase
? Math.min(DesktopIntegration.iconScaleFactor + ICON_SCALE_FACTOR_STEP, MAX_ICON_SCALE_FACTOR)
: Math.max(DesktopIntegration.iconScaleFactor - ICON_SCALE_FACTOR_STEP, MIN_ICON_SCALE_FACTOR);
if (newValue !== DesktopIntegration.iconScaleFactor) {
DesktopIntegration.iconScaleFactor = newValue;
showScaleIndicator(newValue); // 添加视觉反馈
}
}
// 快捷键处理
Shortcut {
context: Qt.ApplicationShortcut
sequences: ["Ctrl++", "Ctrl+="]
onActivated: adjustIconScale(true)
}
Shortcut {
context: Qt.ApplicationShortcut
sequences: ["Ctrl+-"]
onActivated: adjustIconScale(false)
}总结这个功能实现整体上是合理的,主要改进方向是提高代码质量、性能和安全性,同时增强用户体验。通过添加适当的常量定义、输入验证、减少代码重复和优化性能,可以使代码更加健壮和可维护。 |
|
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: 18202781743, wjyrich 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 |
feat: 添加图标缩放功能和键盘快捷键
Pms: BUG-289529
Summary by Sourcery
Introduce interactive icon scaling with keyboard zoom shortcuts, animated transitions, and consistent delegate support
New Features:
Enhancements: