Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 27 additions & 0 deletions desktopintegration.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -232,6 +232,7 @@ DesktopIntegration::DesktopIntegration(QObject *parent)
, m_appWizIntegration(new AppWiz(this))
, m_dockIntegration(new DdeDock(this))
, m_appearanceIntegration(new Appearance(this))
, m_iconScaleFactor(1.0)
{
qCDebug(logDesktopIntegration) << "Initializing DesktopIntegration";
QScopedPointer<DConfig> dconfig(DConfig::create("org.deepin.dde.shell", "org.deepin.ds.launchpad"));
Expand All @@ -254,6 +255,9 @@ DesktopIntegration::DesktopIntegration(QObject *parent)
};
m_compulsoryAppIdList = dconfig->value("compulsoryAppIdList", defaultCompulsoryAppIdList).toStringList();
qCInfo(logDesktopIntegration) << "Compulsory apps loaded:" << m_compulsoryAppIdList.size() << "apps";

m_iconScaleFactor = dconfig->value("iconScaleFactor", 1.0).toReal();
qCInfo(logDesktopIntegration) << "Icon scale factor loaded:" << m_iconScaleFactor;

connect(m_dockIntegration, &DdeDock::directionChanged, this, &DesktopIntegration::dockPositionChanged);
connect(m_dockIntegration, &DdeDock::geometryChanged, this, &DesktopIntegration::dockGeometryChanged);
Expand All @@ -270,3 +274,26 @@ qreal DesktopIntegration::opacity() const
{
return m_appearanceIntegration->opacity();
}

qreal DesktopIntegration::iconScaleFactor() const
{
return m_iconScaleFactor;
}

void DesktopIntegration::setIconScaleFactor(qreal factor)
{
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();
}
5 changes: 5 additions & 0 deletions desktopintegration.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ class DesktopIntegration : public QObject
Q_PROPERTY(QString backgroundUrl READ backgroundUrl NOTIFY backgroundUrlChanged)
Q_PROPERTY(qreal opacity READ opacity NOTIFY opacityChanged FINAL)
Q_PROPERTY(double scaleFactor READ scaleFactor NOTIFY scaleFactorChanged FINAL)
Q_PROPERTY(qreal iconScaleFactor READ iconScaleFactor WRITE setIconScaleFactor NOTIFY iconScaleFactorChanged FINAL)

QML_NAMED_ELEMENT(DesktopIntegration)
QML_SINGLETON
Expand Down Expand Up @@ -69,6 +70,8 @@ class DesktopIntegration : public QObject
Q_INVOKABLE void uninstallApp(const QString & desktopId);
Q_INVOKABLE double scaleFactor() const;
qreal opacity() const;
qreal iconScaleFactor() const;
void setIconScaleFactor(qreal factor);

signals:
void dockPositionChanged();
Expand All @@ -77,6 +80,7 @@ class DesktopIntegration : public QObject
void backgroundUrlChanged();
void opacityChanged();
void scaleFactorChanged();
void iconScaleFactorChanged();

private:
explicit DesktopIntegration(QObject * parent = nullptr);
Expand All @@ -85,4 +89,5 @@ class DesktopIntegration : public QObject
AppWiz * m_appWizIntegration;
DdeDock * m_dockIntegration;
Appearance * m_appearanceIntegration;
qreal m_iconScaleFactor;
};
33 changes: 33 additions & 0 deletions qml/FullscreenFrame.qml
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,15 @@ InputEventItem {
anchors.fill: parent
focus: true
objectName: "FullscreenFrame-BaseLayer"

property real iconScaleFactor: DesktopIntegration.iconScaleFactor

Behavior on iconScaleFactor {
NumberAnimation {
duration: 200
easing.type: Easing.OutQuad
}
}

Shortcut {
context: Qt.ApplicationShortcut
Expand All @@ -75,6 +84,26 @@ InputEventItem {
onActivatedAmbiguously: LauncherController.showHelp()
}

Shortcut {
context: Qt.ApplicationShortcut
sequences: ["Ctrl++", "Ctrl+="]
onActivated: {
if (DesktopIntegration.iconScaleFactor < 1.0) {
DesktopIntegration.iconScaleFactor = Math.min(DesktopIntegration.iconScaleFactor + 0.1, 1.0)
}
}
}

Shortcut {
context: Qt.ApplicationShortcut
sequences: ["Ctrl+-"]
onActivated: {
if (DesktopIntegration.iconScaleFactor > 0.5) {
DesktopIntegration.iconScaleFactor = Math.max(DesktopIntegration.iconScaleFactor - 0.1, 0.5)
}
}
}

readonly property bool isHorizontalDock: DesktopIntegration.dockPosition === Qt.UpArrow || DesktopIntegration.dockPosition === Qt.DownArrow
readonly property int dockSpacing: (isHorizontalDock ? DesktopIntegration.dockGeometry.height : DesktopIntegration.dockGeometry.width) / Screen.devicePixelRatio

Expand Down Expand Up @@ -490,6 +519,8 @@ InputEventItem {
visible: dndItem.currentlyDraggedId !== model.desktopId
iconSource: (iconName && iconName !== "") ? iconName : "application-x-desktop"
icons: folderIcons
iconScaleFactor: baseLayer.iconScaleFactor
transformOrigin: Item.Center
onItemClicked: {
launchApp(desktopId)
}
Expand Down Expand Up @@ -562,6 +593,8 @@ InputEventItem {
width: searchResultGridViewContainer.cellWidth
height: searchResultGridViewContainer.cellHeight
padding: 5
iconScaleFactor: baseLayer.iconScaleFactor
transformOrigin: Item.Center
onItemClicked: {
launchApp(desktopId)
}
Expand Down
5 changes: 3 additions & 2 deletions qml/IconItemDelegate.qml
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ Control {
property bool dndEnabled: false
readonly property bool isWindowedMode: LauncherController.currentFrame === "WindowedFrame"
property alias displayFont: iconItemLabel.font
property real iconScaleFactor: 1.0

Accessible.name: iconItemLabel.text

Expand Down Expand Up @@ -144,7 +145,7 @@ Control {

name: modelData
sourceSize: Qt.size(root.maxIconSizeInFolder, root.maxIconSizeInFolder)
scale: parent.width / 2 / root.maxIconSizeInFolder
scale: (parent.width / 2 / root.maxIconSizeInFolder) * root.iconScaleFactor
palette: DTK.makeIconPalette(root.palette)
theme: ApplicationHelper.DarkType
}
Expand Down Expand Up @@ -174,7 +175,7 @@ Control {
anchors.fill: parent
name: iconSource
sourceSize: Qt.size(root.maxIconSize, root.maxIconSize)
scale: parent.width / root.maxIconSize
scale: (parent.width / root.maxIconSize) * root.iconScaleFactor
palette: DTK.makeIconPalette(root.palette)
theme: ApplicationHelper.DarkType
}
Expand Down
11 changes: 11 additions & 0 deletions src/models/org.deepin.ds.launchpad.json
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,17 @@
"description[zh_CN]": "在搜索时候是否允许搜索Desktop ID。",
"permissions": "readwrite",
"visibility": "public"
},
"iconScaleFactor": {
"value": 1.0,
"serial": 0,
"flags": [],
"name": "Icon Scale Factor",
"name[zh_CN]": "图标缩放比例",
"description": "The scale factor for application icons in fullscreen mode.",
"description[zh_CN]": "全屏模式下应用图标的缩放比例。",
"permissions": "readwrite",
"visibility": "private"
}
}
}