diff --git a/lookandfeel/contents/osd/Osd.qml b/lookandfeel/contents/osd/Osd.qml index 2288ec112..d33e20a4a 100644 --- a/lookandfeel/contents/osd/Osd.qml +++ b/lookandfeel/contents/osd/Osd.qml @@ -38,6 +38,20 @@ PlasmaCore.Dialog { // false for displaying the value as normal text property bool showingProgress: false + property bool animateOpacity: false + + Behavior on opacity { + SequentialAnimation { + // prevent press and hold from flickering + PauseAnimation { duration: 100 } + NumberAnimation { + duration: root.timeout + easing.type: Easing.InQuad + } + } + enabled: root.animateOpacity + } + mainItem: OsdItem { rootItem: root } diff --git a/shell/osd.cpp b/shell/osd.cpp index 0573d5195..3e8bd7067 100644 --- a/shell/osd.cpp +++ b/shell/osd.cpp @@ -125,7 +125,21 @@ void Osd::showText(const QString &icon, const QString &text) void Osd::showOsd() { - m_osdObject->rootObject()->setProperty("visible", true); + m_osdTimer->stop(); + auto *rootObject = m_osdObject->rootObject(); + + // if our OSD understands animating the opacity, do it; + // otherwise just show it to not break existing lnf packages + if (rootObject->property("animateOpacity").isValid()) { + rootObject->setProperty("animateOpacity", false); + rootObject->setProperty("opacity", 1); + rootObject->setProperty("visible", true); + rootObject->setProperty("animateOpacity", true); + rootObject->setProperty("opacity", 0); + } else { + rootObject->setProperty("visible", true); + } + m_osdTimer->start(m_timeout); }