-
Notifications
You must be signed in to change notification settings - Fork 55
feat: add preview follows the system opacity. #1161
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
Reviewer's GuideIntegrates window preview rendering with the system’s configured opacity by connecting to the Appearance1 D-Bus interface, dynamically fetching updates, and overriding paintEvent to draw a rounded background using the current opacity and theme. Sequence Diagram for Opacity Initialization on StartupsequenceDiagram
participant X11WPC as X11WindowPreviewContainer
participant QDBusI as QDBusInterface
participant AppearanceService as org.deepin.dde.Appearance1
X11WPC->>X11WPC: constructor()
activate X11WPC
X11WPC->>QDBusI: new QDBusInterface("org.deepin.dde.Appearance1", ...)
QDBusI-->>X11WPC: m_appearanceInterface
X11WPC->>X11WPC: connect(m_appearanceInterface, Changed, onSystemOpacityChanged)
X11WPC->>X11WPC: getSystemOpacity()
activate X11WPC #LightBlue
X11WPC->>QDBusI: m_appearanceInterface.property("Opacity")
activate QDBusI
QDBusI->>AppearanceService: GetProperty("Opacity")
activate AppearanceService
AppearanceService-->>QDBusI: opacityValue
deactivate AppearanceService
QDBusI-->>X11WPC: opacityVariant
deactivate QDBusI
X11WPC->>X11WPC: m_systemOpacity = opacityVariant.toReal()
deactivate X11WPC #LightBlue
deactivate X11WPC
Sequence Diagram for Handling System Opacity ChangesequenceDiagram
participant AppearanceService as org.deepin.dde.Appearance1
participant QDBusI as QDBusInterface
participant X11WPC as X11WindowPreviewContainer
AppearanceService->>QDBusI: Signal: Changed("windowopacity", ...)
activate QDBusI
QDBusI->>X11WPC: onSystemOpacityChanged("windowopacity", ...)
deactivate QDBusI
activate X11WPC
X11WPC->>X11WPC: getSystemOpacity()
activate X11WPC #LightBlue
X11WPC->>QDBusI: m_appearanceInterface.property("Opacity")
activate QDBusI
QDBusI->>AppearanceService: GetProperty("Opacity")
activate AppearanceService
AppearanceService-->>QDBusI: newOpacityValue
deactivate AppearanceService
QDBusI-->>X11WPC: newOpacityVariant
deactivate QDBusI
X11WPC->>X11WPC: m_systemOpacity = newOpacityVariant.toReal()
X11WPC->>X11WPC: update() /* Triggers repaint */
deactivate X11WPC #LightBlue
deactivate X11WPC
Sequence Diagram for Custom Window Preview PaintingsequenceDiagram
participant QtFramework
participant X11WPC as X11WindowPreviewContainer
participant Painter as QPainter
participant DGuiHelper as DGuiApplicationHelper
participant DStyleH as DStyleHelper
QtFramework->>X11WPC: paintEvent(event)
activate X11WPC
X11WPC->>Painter: new QPainter(this)
Painter-->>X11WPC: painter
X11WPC->>DGuiHelper: DGuiApplicationHelper::instance()->themeType()
activate DGuiHelper
DGuiHelper-->>X11WPC: themeType
deactivate DGuiHelper
X11WPC->>X11WPC: Calculate backgroundColor (using m_systemOpacity, themeType)
X11WPC->>DStyleH: new DStyleHelper(style())
activate DStyleH
DStyleH-->>X11WPC: dstyle
deactivate DStyleH
X11WPC->>DStyleH: dstyle.pixelMetric(DStyle::PM_FrameRadius)
activate DStyleH
DStyleH-->>X11WPC: radius
deactivate DStyleH
X11WPC->>Painter: painter.drawRoundedRect(rect(), radius, radius)
deactivate X11WPC
Updated Class Diagram for X11WindowPreviewContainerclassDiagram
class X11WindowPreviewContainer {
+QDBusInterface* m_appearanceInterface
+double m_systemOpacity
+paintEvent(QPaintEvent* event) void
#getSystemOpacity() double
#onSystemOpacityChanged(const QString& propertyName, const QString& value) void
}
DBlurEffectWidget <|-- X11WindowPreviewContainer
File-Level Changes
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hey @wjyrich - I've reviewed your changes - here's some feedback:
- Verify that the D-Bus signal name and property casing in onSystemOpacityChanged match the Appearance1 interface (e.g. "Opacity" vs "windowopacity") so you reliably update opacity.
- Consider using QDBusReply or QDBusPendingCall to fetch the Appearance1 property instead of QDBusInterface::property for clearer error handling and asynchronous support.
- To avoid reallocating style helpers each frame, cache the corner-radius (DStyle::PM_FrameRadius) outside paintEvent rather than recreating DStyleHelper on every paint.
Prompt for AI Agents
Please address the comments from this code review:
## Overall Comments
- Verify that the D-Bus signal name and property casing in onSystemOpacityChanged match the Appearance1 interface (e.g. "Opacity" vs "windowopacity") so you reliably update opacity.
- Consider using QDBusReply or QDBusPendingCall to fetch the Appearance1 property instead of QDBusInterface::property for clearer error handling and asynchronous support.
- To avoid reallocating style helpers each frame, cache the corner-radius (DStyle::PM_FrameRadius) outside paintEvent rather than recreating DStyleHelper on every paint.
## Individual Comments
### Comment 1
<location> `panels/dock/taskmanager/x11preview.cpp:799` </location>
<code_context>
+ if (m_appearanceInterface && m_appearanceInterface->isValid()) {
+ QVariant opacityVariant = m_appearanceInterface->property("Opacity");
+ if (opacityVariant.isValid()) {
+ double opacity = opacityVariant.toReal();
+ return opacity;
+ }
</code_context>
<issue_to_address>
Clamp opacity value to [0, 1]
The D-Bus property may return values outside the expected range. Use qBound(0.0, opacity, 1.0) to ensure opacity stays within [0, 1] before using it.
</issue_to_address>
<suggested_fix>
<<<<<<< SEARCH
double X11WindowPreviewContainer::getSystemOpacity()
{
if (m_appearanceInterface && m_appearanceInterface->isValid()) {
QVariant opacityVariant = m_appearanceInterface->property("Opacity");
if (opacityVariant.isValid()) {
double opacity = opacityVariant.toReal();
return opacity;
}
=======
#include <QtGlobal>
double X11WindowPreviewContainer::getSystemOpacity()
{
if (m_appearanceInterface && m_appearanceInterface->isValid()) {
QVariant opacityVariant = m_appearanceInterface->property("Opacity");
if (opacityVariant.isValid()) {
double opacity = opacityVariant.toReal();
opacity = qBound(0.0, opacity, 1.0);
return opacity;
}
>>>>>>> REPLACE
</suggested_fix>Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.
6c4cc21 to
a9d2cf9
Compare
fdd1961 to
de61cc2
Compare
as title. PMS-BUG-314371
deepin pr auto review关键摘要:
是否建议立即修改: |
|
[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 |
|
TAG Bot New tag: 2.0.0 |
|
TAG Bot New tag: 2.0.1 |
|
/forcemerge |
|
This pr force merged! (status: unknown) |
as title.
PMS-BUG-314371
Summary by Sourcery
Add system opacity support to X11 window previews by subscribing to the Deepin appearance DBus interface and redrawing the preview background with the current opacity.
New Features: