Skip to content

Commit a182eb8

Browse files
wjyrichdeepin-bot[bot]
authored andcommitted
feat: add display scaling support in desktop integration
1. Added scaleFactor() method to DesktopIntegration class to expose display scaling factor 2. Implemented scaleFactor() in Appearance class with DBus interface to get actual system scaling factor 3. Modified AppItemMenu.qml to only show scaling menu when scale factor is not 1.0 (100%) 4. Added default fallback value of 1.0 when DBus interface is not available The changes allow proper handling of display scaling in the UI, particularly for the application menu where scaling options should only appear when needed (non-default scaling). This improves user experience on high-DPI displays. feat: 在桌面集成中添加显示缩放支持 1. 在DesktopIntegration类中添加scaleFactor()方法以暴露显示缩放因子 2. 在Appearance类中实现scaleFactor(),通过DBus接口获取系统实际缩放因子 3. 修改AppItemMenu.qml,仅在缩放因子不为1.0(100%)时显示缩放菜单 4. 当DBus接口不可用时添加默认回退值1.0 这些更改使得UI能够正确处理显示缩放,特别是应用菜单中的缩放选项现在只会在 需要时(非默认缩放)出现。这提高了在高DPI显示器上的用户体验。 Pms: BUG-317063
1 parent e0eb3bb commit a182eb8

5 files changed

Lines changed: 19 additions & 1 deletion

File tree

desktopintegration.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -249,6 +249,11 @@ DesktopIntegration::DesktopIntegration(QObject *parent)
249249
connect(m_appearanceIntegration, &Appearance::opacityChanged, this, &DesktopIntegration::opacityChanged);
250250
}
251251

252+
double DesktopIntegration::scaleFactor() const
253+
{
254+
return m_appearanceIntegration->scaleFactor();
255+
}
256+
252257
qreal DesktopIntegration::opacity() const
253258
{
254259
return m_appearanceIntegration->opacity();

desktopintegration.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ class DesktopIntegration : public QObject
2121
Q_PROPERTY(uint dockSpacing READ dockSpacing NOTIFY dockSpacingChanged)
2222
Q_PROPERTY(QString backgroundUrl READ backgroundUrl NOTIFY backgroundUrlChanged)
2323
Q_PROPERTY(qreal opacity READ opacity NOTIFY opacityChanged FINAL)
24+
Q_PROPERTY(double scaleFactor READ scaleFactor NOTIFY scaleFactorChanged FINAL)
2425

2526
QML_NAMED_ELEMENT(DesktopIntegration)
2627
QML_SINGLETON
@@ -66,6 +67,7 @@ class DesktopIntegration : public QObject
6667
Q_INVOKABLE void setAutoStart(const QString & desktopId, bool on = true);
6768
Q_INVOKABLE bool shouldSkipConfirmUninstallDialog(const QString & desktopId) const;
6869
Q_INVOKABLE void uninstallApp(const QString & desktopId);
70+
Q_INVOKABLE double scaleFactor() const;
6971
qreal opacity() const;
7072

7173
signals:
@@ -74,6 +76,7 @@ class DesktopIntegration : public QObject
7476
void dockSpacingChanged();
7577
void backgroundUrlChanged();
7678
void opacityChanged();
79+
void scaleFactorChanged();
7780

7881
private:
7982
explicit DesktopIntegration(QObject * parent = nullptr);

shell-launcher-applet/package/launcheritem.qml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@ AppletItem {
9494
iconName: model.iconName,
9595
isFavoriteItem: false,
9696
hideFavoriteMenu: true,
97-
hideDisplayScalingMenu: false,
97+
hideDisplayScalingMenu: Math.abs(DesktopIntegration.scaleFactor - 1.0) < 0.0001,
9898
hideMoveToTopMenu: true
9999
}, additionalProps));
100100
menu.closed.connect(menu.destroy)

src/ddeintegration/appearance.cpp

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -150,3 +150,11 @@ void Appearance::setOpacity(qreal newOpacity)
150150
m_opacity = newOpacity;
151151
emit opacityChanged();
152152
}
153+
154+
double Appearance::scaleFactor() const
155+
{
156+
if (!m_dbusAppearanceIface || !m_dbusAppearanceIface->isValid()) {
157+
return 1.0; // 默认返回1.0(100%缩放)
158+
}
159+
return m_dbusAppearanceIface->GetScaleFactor();
160+
}

src/ddeintegration/appearance.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,8 @@ class Appearance : public QObject
2424
qreal opacity() const;
2525
void setOpacity(qreal newOpacity);
2626

27+
double scaleFactor() const;
28+
2729
signals:
2830
void wallpaperBlurhashChanged();
2931

0 commit comments

Comments
 (0)