Skip to content

Commit 840e7a1

Browse files
committed
feat: add icon scaling with keyboard shortcuts
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
1 parent fd7f19a commit 840e7a1

5 files changed

Lines changed: 79 additions & 2 deletions

File tree

desktopintegration.cpp

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -232,6 +232,7 @@ DesktopIntegration::DesktopIntegration(QObject *parent)
232232
, m_appWizIntegration(new AppWiz(this))
233233
, m_dockIntegration(new DdeDock(this))
234234
, m_appearanceIntegration(new Appearance(this))
235+
, m_iconScaleFactor(1.0)
235236
{
236237
qCDebug(logDesktopIntegration) << "Initializing DesktopIntegration";
237238
QScopedPointer<DConfig> dconfig(DConfig::create("org.deepin.dde.shell", "org.deepin.ds.launchpad"));
@@ -254,6 +255,9 @@ DesktopIntegration::DesktopIntegration(QObject *parent)
254255
};
255256
m_compulsoryAppIdList = dconfig->value("compulsoryAppIdList", defaultCompulsoryAppIdList).toStringList();
256257
qCInfo(logDesktopIntegration) << "Compulsory apps loaded:" << m_compulsoryAppIdList.size() << "apps";
258+
259+
m_iconScaleFactor = dconfig->value("iconScaleFactor", 1.0).toReal();
260+
qCInfo(logDesktopIntegration) << "Icon scale factor loaded:" << m_iconScaleFactor;
257261

258262
connect(m_dockIntegration, &DdeDock::directionChanged, this, &DesktopIntegration::dockPositionChanged);
259263
connect(m_dockIntegration, &DdeDock::geometryChanged, this, &DesktopIntegration::dockGeometryChanged);
@@ -270,3 +274,26 @@ qreal DesktopIntegration::opacity() const
270274
{
271275
return m_appearanceIntegration->opacity();
272276
}
277+
278+
qreal DesktopIntegration::iconScaleFactor() const
279+
{
280+
return m_iconScaleFactor;
281+
}
282+
283+
void DesktopIntegration::setIconScaleFactor(qreal factor)
284+
{
285+
if (qFuzzyCompare(m_iconScaleFactor, factor)) {
286+
return;
287+
}
288+
289+
m_iconScaleFactor = factor;
290+
291+
// 保存到 dconfig
292+
QScopedPointer<DConfig> dconfig(DConfig::create("org.deepin.dde.shell", "org.deepin.ds.launchpad"));
293+
if (dconfig->isValid()) {
294+
dconfig->setValue("iconScaleFactor", factor);
295+
qCInfo(logDesktopIntegration) << "Icon scale factor saved:" << factor;
296+
}
297+
298+
emit iconScaleFactorChanged();
299+
}

desktopintegration.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ class DesktopIntegration : public QObject
2222
Q_PROPERTY(QString backgroundUrl READ backgroundUrl NOTIFY backgroundUrlChanged)
2323
Q_PROPERTY(qreal opacity READ opacity NOTIFY opacityChanged FINAL)
2424
Q_PROPERTY(double scaleFactor READ scaleFactor NOTIFY scaleFactorChanged FINAL)
25+
Q_PROPERTY(qreal iconScaleFactor READ iconScaleFactor WRITE setIconScaleFactor NOTIFY iconScaleFactorChanged FINAL)
2526

2627
QML_NAMED_ELEMENT(DesktopIntegration)
2728
QML_SINGLETON
@@ -69,6 +70,8 @@ class DesktopIntegration : public QObject
6970
Q_INVOKABLE void uninstallApp(const QString & desktopId);
7071
Q_INVOKABLE double scaleFactor() const;
7172
qreal opacity() const;
73+
qreal iconScaleFactor() const;
74+
void setIconScaleFactor(qreal factor);
7275

7376
signals:
7477
void dockPositionChanged();
@@ -77,6 +80,7 @@ class DesktopIntegration : public QObject
7780
void backgroundUrlChanged();
7881
void opacityChanged();
7982
void scaleFactorChanged();
83+
void iconScaleFactorChanged();
8084

8185
private:
8286
explicit DesktopIntegration(QObject * parent = nullptr);
@@ -85,4 +89,5 @@ class DesktopIntegration : public QObject
8589
AppWiz * m_appWizIntegration;
8690
DdeDock * m_dockIntegration;
8791
Appearance * m_appearanceIntegration;
92+
qreal m_iconScaleFactor;
8893
};

qml/FullscreenFrame.qml

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,15 @@ InputEventItem {
6767
anchors.fill: parent
6868
focus: true
6969
objectName: "FullscreenFrame-BaseLayer"
70+
71+
property real iconScaleFactor: DesktopIntegration.iconScaleFactor
72+
73+
Behavior on iconScaleFactor {
74+
NumberAnimation {
75+
duration: 200
76+
easing.type: Easing.OutQuad
77+
}
78+
}
7079

7180
Shortcut {
7281
context: Qt.ApplicationShortcut
@@ -75,6 +84,26 @@ InputEventItem {
7584
onActivatedAmbiguously: LauncherController.showHelp()
7685
}
7786

87+
Shortcut {
88+
context: Qt.ApplicationShortcut
89+
sequences: ["Ctrl++", "Ctrl+="]
90+
onActivated: {
91+
if (DesktopIntegration.iconScaleFactor < 1.0) {
92+
DesktopIntegration.iconScaleFactor = Math.min(DesktopIntegration.iconScaleFactor + 0.1, 1.0)
93+
}
94+
}
95+
}
96+
97+
Shortcut {
98+
context: Qt.ApplicationShortcut
99+
sequences: ["Ctrl+-"]
100+
onActivated: {
101+
if (DesktopIntegration.iconScaleFactor > 0.5) {
102+
DesktopIntegration.iconScaleFactor = Math.max(DesktopIntegration.iconScaleFactor - 0.1, 0.5)
103+
}
104+
}
105+
}
106+
78107
readonly property bool isHorizontalDock: DesktopIntegration.dockPosition === Qt.UpArrow || DesktopIntegration.dockPosition === Qt.DownArrow
79108
readonly property int dockSpacing: (isHorizontalDock ? DesktopIntegration.dockGeometry.height : DesktopIntegration.dockGeometry.width) / Screen.devicePixelRatio
80109

@@ -490,6 +519,8 @@ InputEventItem {
490519
visible: dndItem.currentlyDraggedId !== model.desktopId
491520
iconSource: (iconName && iconName !== "") ? iconName : "application-x-desktop"
492521
icons: folderIcons
522+
iconScaleFactor: baseLayer.iconScaleFactor
523+
transformOrigin: Item.Center
493524
onItemClicked: {
494525
launchApp(desktopId)
495526
}
@@ -562,6 +593,8 @@ InputEventItem {
562593
width: searchResultGridViewContainer.cellWidth
563594
height: searchResultGridViewContainer.cellHeight
564595
padding: 5
596+
iconScaleFactor: baseLayer.iconScaleFactor
597+
transformOrigin: Item.Center
565598
onItemClicked: {
566599
launchApp(desktopId)
567600
}

qml/IconItemDelegate.qml

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ Control {
3030
property bool dndEnabled: false
3131
readonly property bool isWindowedMode: LauncherController.currentFrame === "WindowedFrame"
3232
property alias displayFont: iconItemLabel.font
33+
property real iconScaleFactor: 1.0
3334

3435
Accessible.name: iconItemLabel.text
3536

@@ -144,7 +145,7 @@ Control {
144145

145146
name: modelData
146147
sourceSize: Qt.size(root.maxIconSizeInFolder, root.maxIconSizeInFolder)
147-
scale: parent.width / 2 / root.maxIconSizeInFolder
148+
scale: (parent.width / 2 / root.maxIconSizeInFolder) * root.iconScaleFactor
148149
palette: DTK.makeIconPalette(root.palette)
149150
theme: ApplicationHelper.DarkType
150151
}
@@ -174,7 +175,7 @@ Control {
174175
anchors.fill: parent
175176
name: iconSource
176177
sourceSize: Qt.size(root.maxIconSize, root.maxIconSize)
177-
scale: parent.width / root.maxIconSize
178+
scale: (parent.width / root.maxIconSize) * root.iconScaleFactor
178179
palette: DTK.makeIconPalette(root.palette)
179180
theme: ApplicationHelper.DarkType
180181
}

src/models/org.deepin.ds.launchpad.json

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,17 @@
8686
"description[zh_CN]": "在搜索时候是否允许搜索Desktop ID。",
8787
"permissions": "readwrite",
8888
"visibility": "public"
89+
},
90+
"iconScaleFactor": {
91+
"value": 1.0,
92+
"serial": 0,
93+
"flags": [],
94+
"name": "Icon Scale Factor",
95+
"name[zh_CN]": "图标缩放比例",
96+
"description": "The scale factor for application icons in fullscreen mode.",
97+
"description[zh_CN]": "全屏模式下应用图标的缩放比例。",
98+
"permissions": "readwrite",
99+
"visibility": "private"
89100
}
90101
}
91102
}

0 commit comments

Comments
 (0)