Skip to content

Commit e6f06ca

Browse files
committed
wip
1 parent 3742ee8 commit e6f06ca

2 files changed

Lines changed: 12 additions & 10 deletions

File tree

src/Plugins/Qt/qt_floating_toast.cpp

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -81,8 +81,9 @@ void
8181
QtFloatingToast::updatePosition (QWidget* anchorWidget) {
8282
if (!anchorWidget) return;
8383
QWidget* window= anchorWidget->window ();
84-
int x = (window->width () - width ()) / 2;
85-
int y = (window->height () - height ()) / 8;
84+
QRect geo = window->geometry ();
85+
int x = geo.x () + (geo.width () - width ()) / 2;
86+
int y = geo.y () + (geo.height () - height ()) / 8;
8687
move (x, y);
8788
}
8889

@@ -99,9 +100,9 @@ QtFloatingToast::startFadeOut () {
99100
fadeAnimation_->stop ();
100101
fadeAnimation_->setStartValue (1.0);
101102
fadeAnimation_->setEndValue (0.0);
102-
disconnect (fadeAnimation_, &QPropertyAnimation::finished, nullptr, nullptr);
103-
connect (fadeAnimation_, &QPropertyAnimation::finished, this,
104-
&QObject::deleteLater);
103+
if (fadeConnection_) disconnect (fadeConnection_);
104+
fadeConnection_= connect (fadeAnimation_, &QPropertyAnimation::finished, this,
105+
&QObject::deleteLater);
105106
fadeAnimation_->start ();
106107
}
107108

src/Plugins/Qt/qt_floating_toast.hpp

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -42,11 +42,12 @@ class QtFloatingToast : public QWidget {
4242
void startFadeIn ();
4343
void startFadeOut ();
4444

45-
QLabel* label_ = nullptr;
46-
QHBoxLayout* layout_ = nullptr;
47-
QPropertyAnimation* fadeAnimation_= nullptr;
48-
QTimer* hideTimer_ = nullptr;
49-
Type type_ = Success;
45+
QLabel* label_ = nullptr;
46+
QHBoxLayout* layout_ = nullptr;
47+
QPropertyAnimation* fadeAnimation_= nullptr;
48+
QTimer* hideTimer_ = nullptr;
49+
QMetaObject::Connection fadeConnection_;
50+
Type type_= Success;
5051
};
5152

5253
#endif

0 commit comments

Comments
 (0)