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
26 changes: 18 additions & 8 deletions applets/dde-appearance/appearanceapplet.cpp
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 @@ -39,11 +39,7 @@ bool AppearanceApplet::load()

qreal AppearanceApplet::opacity() const
{
if (!m_interface)
return -1;

// The minimum opacity is 0.2
return std::max(0.2, m_interface->opacity());
return m_opacity;
}

void AppearanceApplet::initDBusProxy()
Expand All @@ -56,11 +52,25 @@ void AppearanceApplet::initDBusProxy()
if (!m_interface->isValid()) {
qWarning() << "Failed to proxy Appearance, error:" << m_interface->lastError();
m_interface.reset();
updateOpacity(-1);
return;
}

m_interface->setSync(false);
QObject::connect(m_interface.data(), &org::deepin::dde::Appearance1::OpacityChanged, this, &AppearanceApplet::opacityChanged);
QObject::connect(m_interface.data(), &org::deepin::dde::Appearance1::OpacityChanged,
this, &AppearanceApplet::updateOpacity);
updateOpacity(m_interface->opacity());
}

void AppearanceApplet::updateOpacity(qreal opacity)
{
if (opacity >= 0) {
// The minimum opacity is 0.2
opacity = std::max(0.2, opacity);
}
if (qFuzzyCompare(m_opacity, opacity))
return;

m_opacity = opacity;
Q_EMIT opacityChanged();
}

Expand Down
4 changes: 3 additions & 1 deletion applets/dde-appearance/appearanceapplet.h
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 @@ -24,8 +24,10 @@ class AppearanceApplet : public DApplet
void opacityChanged();
private:
void initDBusProxy();
void updateOpacity(qreal opacity);
private:
QScopedPointer<org::deepin::dde::Appearance1> m_interface;
qreal m_opacity = -1;
};

}
Expand Down
2 changes: 1 addition & 1 deletion panels/dock/taskmanager/taskmanager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -538,8 +538,8 @@ void TaskManager::modifyOpacityChanged()
DS_NAMESPACE::DAppletBridge appearanceBridge("org.deepin.ds.dde-appearance");
auto appearanceApplet = appearanceBridge.applet();
if (appearanceApplet) {
double opacity = appearanceApplet->property("opacity").toReal();
if (auto x11Monitor = qobject_cast<X11WindowMonitor*>(m_windowMonitor.data())) {
double opacity = appearanceApplet->property("opacity").toReal();
x11Monitor->setPreviewOpacity(opacity);
}
} else {
Expand Down
Loading