diff --git a/qtacryliceffecthelper.cpp b/qtacryliceffecthelper.cpp index 3da4e6d..62675dd 100644 --- a/qtacryliceffecthelper.cpp +++ b/qtacryliceffecthelper.cpp @@ -56,6 +56,7 @@ void QtAcrylicEffectHelper::install(const QWindow *window) connect(m_window, &QWindow::xChanged, this, &QtAcrylicEffectHelper::needsRepaint); connect(m_window, &QWindow::yChanged, this, &QtAcrylicEffectHelper::needsRepaint); connect(m_window, &QWindow::activeChanged, this, &QtAcrylicEffectHelper::needsRepaint); + // What's the difference between "visibility" and "window state"? //connect(m_window, &QWindow::visibilityChanged, this, &QtAcrylicEffectHelper::needsRepaint); connect(m_window, &QWindow::windowStateChanged, this, &QtAcrylicEffectHelper::needsRepaint); #ifdef Q_OS_WINDOWS diff --git a/qtacrylicitem.cpp b/qtacrylicitem.cpp index 7bc7c8b..03b64ae 100644 --- a/qtacrylicitem.cpp +++ b/qtacrylicitem.cpp @@ -31,11 +31,14 @@ QtAcrylicItem::QtAcrylicItem(QQuickItem *parent) : QQuickPaintedItem(parent) { connect(this, &QtAcrylicItem::windowChanged, this, [this](QQuickWindow *win){ + if (m_repaintConnection) { + disconnect(m_repaintConnection); + } m_acrylicHelper.uninstall(); if (win) { m_acrylicHelper.install(win); m_acrylicHelper.updateAcrylicBrush(); - connect(&m_acrylicHelper, &QtAcrylicEffectHelper::needsRepaint, this, [this](){ + m_repaintConnection = connect(&m_acrylicHelper, &QtAcrylicEffectHelper::needsRepaint, this, [this](){ update(); }); } diff --git a/qtacrylicitem.h b/qtacrylicitem.h index ec6b840..5ae6e9e 100644 --- a/qtacrylicitem.h +++ b/qtacrylicitem.h @@ -77,4 +77,5 @@ Q_SIGNALS: private: QtAcrylicEffectHelper m_acrylicHelper; bool m_frameVisible = true; + QMetaObject::Connection m_repaintConnection = {}; };