From 38ac201e9fc4098e4ce374bf1ea934ab08a3a1c3 Mon Sep 17 00:00:00 2001 From: Tsu Jan Date: Tue, 29 Aug 2023 18:37:51 +0330 Subject: [PATCH] Fixed a rare issue in warning bar geometry --- ChangeLog | 1 + NEWS | 2 +- feathernotes/warningbar.h | 17 +++++++++++++---- 3 files changed, 15 insertions(+), 5 deletions(-) diff --git a/ChangeLog b/ChangeLog index 90104847..371ae205 100644 --- a/ChangeLog +++ b/ChangeLog @@ -9,6 +9,7 @@ V1.1.1 * Protect the file type filters of file dialogs from bad translations. * Don't insert garbage when an image can't be loaded. * Start searching in node names when Slash is pressed inside the side-pane. + * Fixed a rare issue in the geometry of a warning bar animated during window resizing. * Changed "Qt5" to "Qt" in the meta-info file (the Qt5 support cannot last indefinitely). V1.1.0 diff --git a/NEWS b/NEWS index dc932ec5..7a84ba02 100644 --- a/NEWS +++ b/NEWS @@ -1,5 +1,5 @@ Latest version: - 15 Aug 2023, V1.1.1 + 29 Aug 2023, V1.1.1 See "ChangeLog" for changes. diff --git a/feathernotes/warningbar.h b/feathernotes/warningbar.h index dd3df3b6..36c85c45 100644 --- a/feathernotes/warningbar.h +++ b/feathernotes/warningbar.h @@ -1,5 +1,5 @@ /* - * Copyright (C) Pedram Pourang (aka Tsu Jan) 2022 + * Copyright (C) Pedram Pourang (aka Tsu Jan) 2022-2023 * * FeatherNotes is free software: you can redistribute it and/or modify it * under the terms of the GNU General Public License as published by the @@ -78,7 +78,7 @@ class WarningBar : public QWidget if (parent) { // compress the bar vertically and show it with animation - QTimer::singleShot (anotherBar ? DURATION + 10 : 0, this, [=]() { + QTimer::singleShot (anotherBar ? DURATION + 10 : 0, this, [this, parent]() { parent->installEventFilter (this); int h = grid_->minimumHeightForWidth (parent->width()) + grid_->contentsMargins().bottom(); QRect g (0, parent->height() - h, parent->width(), h); @@ -133,7 +133,17 @@ class WarningBar : public QWidget if (QWidget *w = qobject_cast(o)) { if (w == parentWidget()) - { // compress the bar as far as its text is shown completely + { + if (animation_) + { + animation_->stop(); + if (isClosing_) + { + this->deleteLater(); + return false; + } + } + /* compress the bar as far as its text is shown completely */ int h = grid_->minimumHeightForWidth (w->width()) + grid_->contentsMargins().bottom(); setGeometry (QRect (0, w->height() - h, w->width(), h)); } @@ -157,7 +167,6 @@ public slots: if (!isClosing_) { isClosing_ = true; - parentWidget()->removeEventFilter (this); // no movement on closing animation_->stop(); animation_->setStartValue (geometry()); animation_->setEndValue (QRect (0, parentWidget()->height(), parentWidget()->width(), 0));