Skip to content

Commit

Permalink
fix: the opacity of preview window isn't changed
Browse files Browse the repository at this point in the history
the opacity isn't changed by changing the settings in dcc
Add the slot to the signal that opacity changes in dcc

Log:
Bug: https://pms.uniontech.com/bug-view-273041.html
  • Loading branch information
FeiWang1119 authored and BLumia committed Sep 11, 2024
1 parent ffe6ed6 commit 042b33e
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 0 deletions.
19 changes: 19 additions & 0 deletions panels/dock/taskmanager/x11preview.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -391,6 +391,12 @@ class AppItemWindowDeletegate : public QAbstractItemDelegate

};

const QString AppearanceService = QStringLiteral("org.deepin.dde.Appearance1");
const QString AppearancePath = QStringLiteral("/org/deepin/dde/Appearance1");
const QString PropertiesInterface = QStringLiteral("org.freedesktop.DBus.Properties");
const QString PropertiesChanged = QStringLiteral("PropertiesChanged");
const QString OpacityStr = QStringLiteral("Opacity");

X11WindowPreviewContainer::X11WindowPreviewContainer(X11WindowMonitor* monitor, QWidget *parent)
: DBlurEffectWidget(parent)
, m_direction(0)
Expand All @@ -407,6 +413,8 @@ X11WindowPreviewContainer::X11WindowPreviewContainer(X11WindowMonitor* monitor,
setMouseTracking(true);
initUI();

QDBusConnection::sessionBus().connect(AppearanceService, AppearancePath, PropertiesInterface, PropertiesChanged, this, SLOT(onPropertiesChanged(QDBusMessage)));

connect(m_hideTimer, &QTimer::timeout, this, &X11WindowPreviewContainer::callHide);

connect(m_closeAllButton, &DIconButton::clicked, this, [this](){
Expand All @@ -428,6 +436,17 @@ X11WindowPreviewContainer::X11WindowPreviewContainer(X11WindowMonitor* monitor,

}

void X11WindowPreviewContainer::onPropertiesChanged(const QDBusMessage &message)
{
QVariantMap changedProps = qdbus_cast<QVariantMap>(message.arguments().at(1).value<QDBusArgument>());
for (QVariantMap::const_iterator it = changedProps.cbegin(); it != changedProps.cend(); ++it) {
if (it.key().toLatin1() == OpacityStr) {
setMaskAlpha(it.value().toFloat() * 255);
return;
}
}
}

void X11WindowPreviewContainer::showPreview(const QPointer<AppItem> &item, const QPointer<QWindow> &window, int32_t previewXoffset, int32_t previewYoffset, uint32_t direction)
{
if (!m_previewItem.isNull()) {
Expand Down
2 changes: 2 additions & 0 deletions panels/dock/taskmanager/x11preview.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
#include <DBlurEffectWidget>
#include <DGuiApplicationHelper>
#include <DIconButton>
#include <QDBusMessage>

DWIDGET_USE_NAMESPACE

Expand Down Expand Up @@ -89,6 +90,7 @@ public Q_SLOTS:
private Q_SLOTS:
void updateOrientation();
void callHide();
void onPropertiesChanged(const QDBusMessage &message);

private:
bool m_isPreviewEntered;
Expand Down

0 comments on commit 042b33e

Please sign in to comment.