Skip to content
Closed
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
1 change: 1 addition & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ set(SOURCE_FILES
launchercontroller.cpp launchercontroller.h
debughelper.cpp debughelper.h
inputeventitem.h inputeventitem.cpp
src/quick/painteddciicon.h src/quick/painteddciicon.cpp
)

set(QML_FILES
Expand Down
8 changes: 7 additions & 1 deletion qml/Helper.qml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// SPDX-FileCopyrightText: 2024 UnionTech Software Technology Co., Ltd.
// SPDX-FileCopyrightText: 2024 - 2026 UnionTech Software Technology Co., Ltd.
//
// SPDX-License-Identifier: GPL-3.0-or-later

Expand Down Expand Up @@ -40,6 +40,12 @@ QtObject {
}
}

// Snap a logical pixel value so that value * DPR lands on an integer
// physical pixel, avoiding sub-pixel texture sampling blur in Scene Graph.
function pixelAligned(value, dpr) {
return Math.round(value * dpr) / dpr
}

function generateDragMimeData(desktopId, dockOnly = false) {
// In some cases an app is not allowed to be pinned onto dock via drag-n-drop;
// We only insert the MIME data for dde-dock in those allowed cases.
Expand Down
19 changes: 15 additions & 4 deletions qml/windowed/BottomBar.qml
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
// SPDX-FileCopyrightText: 2024 UnionTech Software Technology Co., Ltd.
// SPDX-FileCopyrightText: 2024 - 2026 UnionTech Software Technology Co., Ltd.
//
// SPDX-License-Identifier: GPL-3.0-or-later

import QtQuick 2.15
import QtQuick.Layouts 1.15
import QtQuick.Controls 2.15
import QtQuick.Window 2.15
import org.deepin.dtk 1.0
import org.deepin.ds 1.0
import org.deepin.dtk.style 1.0 as DStyle
Expand All @@ -20,12 +21,17 @@ Control {
property Item nextKeyTabTarget
property alias searchEdit: searchEdit

padding: 10
padding: Helper.pixelAligned(10, Screen.devicePixelRatio)

contentItem: RowLayout {
ToolButton {
id: shutdownBtn
icon.name: "shutdown"
contentItem: PaintedDciIcon {
name: "shutdown"
sourceSize: Qt.size(16, 16)
width: 16
height: 16
}
background: ItemBackground {
button: shutdownBtn
}
Expand Down Expand Up @@ -95,7 +101,12 @@ Control {

ToolButton {
id: fullscreenBtn
icon.name: "launcher_fullscreen"
contentItem: PaintedDciIcon {
name: "launcher_fullscreen"
sourceSize: Qt.size(16, 16)
width: 16
height: 16
}
background: ItemBackground {
button: fullscreenBtn
}
Expand Down
40 changes: 23 additions & 17 deletions qml/windowed/SideBar.qml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// SPDX-FileCopyrightText: 2024 UnionTech Software Technology Co., Ltd.
// SPDX-FileCopyrightText: 2024 - 2026 UnionTech Software Technology Co., Ltd.
//
// SPDX-License-Identifier: GPL-3.0-or-later

Expand All @@ -15,7 +15,7 @@ import org.deepin.launchpad 1.0
import org.deepin.launchpad.models 1.0

ColumnLayout {
spacing: 10
spacing: Helper.pixelAligned(10, Screen.devicePixelRatio)

property bool isFreeSort: CategorizedSortProxyModel.categoryType === CategorizedSortProxyModel.FreeCategory
property Item keyTabTarget: title
Expand Down Expand Up @@ -92,27 +92,29 @@ ColumnLayout {
KeyNavigation.down: computer
KeyNavigation.up: setting
KeyNavigation.tab: nextKeyTabTarget
topPadding: 7
bottomPadding: 5
topPadding: Helper.pixelAligned(7, Screen.devicePixelRatio)
bottomPadding: Helper.pixelAligned(5, Screen.devicePixelRatio)
ToolTip.visible: hovered
ToolTip.delay: 500
ToolTip.text: qsTr("Sorting Mode")

contentItem: ColumnLayout {
spacing: 2
D.DciIcon {
PaintedDciIcon {
sourceSize: Qt.size(16, 16)
width: 16
height: 16
name: isFreeSort ? categorizedIcon("freeSort") : categorizedIcon(CategorizedSortProxyModel.categoryType)
palette: D.DTK.makeIconPalette(title.palette)
theme: D.DTK.toColorType(title.palette.window)
foreground: title.palette.windowText
Layout.alignment: Qt.AlignHCenter
}

D.DciIcon {
PaintedDciIcon {
name: "arrow"
sourceSize: Qt.size(12, 12)
palette: D.DTK.makeIconPalette(title.palette)
theme: D.DTK.toColorType(title.palette.window)
width: 12
height: 12
foreground: title.palette.windowText
Layout.alignment: Qt.AlignHCenter
}
}
Expand All @@ -133,15 +135,19 @@ ColumnLayout {

component SideBarButton: D.ActionButton {
id: btn
property alias iconSource: paintedIcon.name
ToolTip.visible: hovered
ToolTip.delay: 500
Layout.alignment: Qt.AlignCenter
focusPolicy: Qt.NoFocus
// don't inherit window's windowText (it's has opacity of 0.7 in dtkgui.)
palette.windowText: D.ColorSelector.textColor
icon {
contentItem: PaintedDciIcon {
id: paintedIcon
width: 16
height: 16
sourceSize: Qt.size(16, 16)
foreground: D.ColorSelector.textColor
}
background: ItemBackground {
button: btn
Expand All @@ -150,7 +156,7 @@ ColumnLayout {

SideBarButton {
id: computer
icon.name: "computer-symbolic"
iconSource: "computer-symbolic"
ToolTip.text: qsTr("Computer")
KeyNavigation.down: images
KeyNavigation.up: title
Expand All @@ -161,7 +167,7 @@ ColumnLayout {

SideBarButton {
id: images
icon.name: "folder-pictures-symbolic"
iconSource: "folder-pictures-symbolic"
ToolTip.text: qsTr("Pictures")
KeyNavigation.down: documents
KeyNavigation.up: computer
Expand All @@ -172,7 +178,7 @@ ColumnLayout {

SideBarButton {
id: documents
icon.name: "folder-documents-symbolic"
iconSource: "folder-documents-symbolic"
ToolTip.text: qsTr("Documents")
KeyNavigation.down: desktop
KeyNavigation.up: images
Expand All @@ -183,7 +189,7 @@ ColumnLayout {

SideBarButton {
id: desktop
icon.name: "user-desktop-symbolic"
iconSource: "user-desktop-symbolic"
ToolTip.text: qsTr("Desktop")
KeyNavigation.down: setting
KeyNavigation.up: documents
Expand All @@ -194,7 +200,7 @@ ColumnLayout {

SideBarButton {
id: setting
icon.name: "setting"
iconSource: "setting"
ToolTip.text: qsTr("Control Center")
KeyNavigation.down: title
KeyNavigation.up: desktop
Expand All @@ -209,6 +215,6 @@ ColumnLayout {

Item {
height: title.height
Layout.bottomMargin: 10
Layout.bottomMargin: Helper.pixelAligned(10, Screen.devicePixelRatio)
}
}
6 changes: 3 additions & 3 deletions qml/windowed/WindowedFrame.qml
Original file line number Diff line number Diff line change
Expand Up @@ -84,8 +84,8 @@ InputEventItem {
anchors.left: parent.left
anchors.top: parent.top
anchors.bottom: parent.bottom
anchors.topMargin: 10
anchors.leftMargin: 10
anchors.topMargin: Helper.pixelAligned(10, Screen.devicePixelRatio)
anchors.leftMargin: Helper.pixelAligned(10, Screen.devicePixelRatio)
nextKeyTabTarget: bottomBar.keyTabTarget
}

Expand All @@ -95,7 +95,7 @@ InputEventItem {
anchors.left: sideBar.right
anchors.top: baseLayer.top
anchors.bottom: bottomBar.top
anchors.leftMargin: 10
anchors.leftMargin: Helper.pixelAligned(10, Screen.devicePixelRatio)

property Palette backgroundColor: Palette {
normal {
Expand Down
92 changes: 92 additions & 0 deletions src/quick/painteddciicon.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,92 @@
// SPDX-FileCopyrightText: 2026 UnionTech Software Technology Co., Ltd.
//
// SPDX-License-Identifier: GPL-3.0-or-later

#include "painteddciicon.h"

#include <QPainter>

Check warning on line 7 in src/quick/painteddciicon.cpp

View workflow job for this annotation

GitHub Actions / cppcheck

Include file: <QPainter> not found. Please note: Cppcheck does not need standard library headers to get proper results.
#include <QQuickWindow>

Check warning on line 8 in src/quick/painteddciicon.cpp

View workflow job for this annotation

GitHub Actions / cppcheck

Include file: <QQuickWindow> not found. Please note: Cppcheck does not need standard library headers to get proper results.
#include <QGuiApplication>

Check warning on line 9 in src/quick/painteddciicon.cpp

View workflow job for this annotation

GitHub Actions / cppcheck

Include file: <QGuiApplication> not found. Please note: Cppcheck does not need standard library headers to get proper results.
#include <DDciIconPalette>

Check warning on line 10 in src/quick/painteddciicon.cpp

View workflow job for this annotation

GitHub Actions / cppcheck

Include file: <DDciIconPalette> not found. Please note: Cppcheck does not need standard library headers to get proper results.
#include <DGuiApplicationHelper>

Check warning on line 11 in src/quick/painteddciicon.cpp

View workflow job for this annotation

GitHub Actions / cppcheck

Include file: <DGuiApplicationHelper> not found. Please note: Cppcheck does not need standard library headers to get proper results.

DGUI_USE_NAMESPACE

PaintedDciIcon::PaintedDciIcon(QQuickItem *parent)
: QQuickPaintedItem(parent)
{
setRenderTarget(QQuickPaintedItem::Image);

connect(DGuiApplicationHelper::instance(), &DGuiApplicationHelper::themeTypeChanged,
this, [this]() { update(); });
}

void PaintedDciIcon::paint(QPainter *painter)
{
if (m_dciIcon.isNull())
return;

qreal dpr = window() ? window()->devicePixelRatio() : qApp->devicePixelRatio();
auto appTheme = DGuiApplicationHelper::instance()->themeType();
DDciIcon::Theme theme = (appTheme == DGuiApplicationHelper::DarkType)
? DDciIcon::Dark : DDciIcon::Light;

QPalette pa = qApp->palette();
DDciIconPalette palette(
m_foreground.isValid() ? m_foreground : pa.windowText().color(),
pa.window().color(),
pa.highlight().color(),
pa.highlightedText().color()
);

int iconW = m_sourceSize.isValid() ? m_sourceSize.width() : qRound(width());
int iconH = m_sourceSize.isValid() ? m_sourceSize.height() : qRound(height());
QRect iconRect(0, 0, iconW, iconH);
QRect itemRect(0, 0, qRound(width()), qRound(height()));
iconRect.moveCenter(itemRect.center());
m_dciIcon.paint(painter, iconRect, dpr, theme, DDciIcon::Normal,
Qt::AlignCenter, palette);
}

QString PaintedDciIcon::name() const
{
return m_name;
}

void PaintedDciIcon::setName(const QString &name)
{
if (m_name == name)
return;
m_name = name;
m_dciIcon = DDciIcon::fromTheme(m_name);
emit nameChanged();
update();
}

QColor PaintedDciIcon::foreground() const

Check warning on line 66 in src/quick/painteddciicon.cpp

View workflow job for this annotation

GitHub Actions / cppcheck

The function 'foreground' is never used.
{
return m_foreground;
}

void PaintedDciIcon::setForeground(const QColor &color)

Check warning on line 71 in src/quick/painteddciicon.cpp

View workflow job for this annotation

GitHub Actions / cppcheck

The function 'setForeground' is never used.
{
if (m_foreground == color)
return;
m_foreground = color;
emit foregroundChanged();
update();
}

QSize PaintedDciIcon::sourceSize() const

Check warning on line 80 in src/quick/painteddciicon.cpp

View workflow job for this annotation

GitHub Actions / cppcheck

The function 'sourceSize' is never used.
{
return m_sourceSize;
}

void PaintedDciIcon::setSourceSize(const QSize &size)

Check warning on line 85 in src/quick/painteddciicon.cpp

View workflow job for this annotation

GitHub Actions / cppcheck

The function 'setSourceSize' is never used.
{
if (m_sourceSize == size)
return;
m_sourceSize = size;
emit sourceSizeChanged();
update();
}
48 changes: 48 additions & 0 deletions src/quick/painteddciicon.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
// SPDX-FileCopyrightText: 2026 UnionTech Software Technology Co., Ltd.
//
// SPDX-License-Identifier: GPL-3.0-or-later

#ifndef PAINTEDDCIICON_H
#define PAINTEDDCIICON_H

#include <QQuickPaintedItem>

Check warning on line 8 in src/quick/painteddciicon.h

View workflow job for this annotation

GitHub Actions / cppcheck

Include file: <QQuickPaintedItem> not found. Please note: Cppcheck does not need standard library headers to get proper results.
#include <QQmlEngine>
#include <DDciIcon>

DGUI_USE_NAMESPACE

class PaintedDciIcon : public QQuickPaintedItem
{
Q_OBJECT
QML_ELEMENT
Q_PROPERTY(QString name READ name WRITE setName NOTIFY nameChanged)
Q_PROPERTY(QColor foreground READ foreground WRITE setForeground NOTIFY foregroundChanged)
Q_PROPERTY(QSize sourceSize READ sourceSize WRITE setSourceSize NOTIFY sourceSizeChanged)

public:
explicit PaintedDciIcon(QQuickItem *parent = nullptr);

void paint(QPainter *painter) override;

QString name() const;
void setName(const QString &name);

QColor foreground() const;
void setForeground(const QColor &color);

QSize sourceSize() const;
void setSourceSize(const QSize &size);

signals:
void nameChanged();
void foregroundChanged();
void sourceSizeChanged();

private:
QString m_name;
QColor m_foreground;
QSize m_sourceSize;
DDciIcon m_dciIcon;
};

#endif // PAINTEDDCIICON_H
Loading