fixed notebookpagedroppreview animation
This commit is contained in:
@@ -54,7 +54,7 @@ ChatWidgetView::layoutMessages()
|
||||
redraw |= message.get()->layout(this->width(), true);
|
||||
}
|
||||
|
||||
int h = this->height();
|
||||
int h = this->height() - 8;
|
||||
|
||||
for (int i = messages.size() - 1; i >= 0; i--) {
|
||||
auto *message = messages[i].get();
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
#include "widgets/notebookpagedroppreview.h"
|
||||
#include "colorscheme.h"
|
||||
|
||||
#include <QDebug>
|
||||
#include <QPainter>
|
||||
|
||||
namespace chatterino {
|
||||
@@ -10,8 +11,10 @@ NotebookPageDropPreview::NotebookPageDropPreview(QWidget *parent)
|
||||
: QWidget(parent)
|
||||
, positionAnimation(this, "geometry")
|
||||
, desiredGeometry()
|
||||
, animate(false)
|
||||
{
|
||||
setHidden(true);
|
||||
this->positionAnimation.setEasingCurve(QEasingCurve(QEasingCurve::InCubic));
|
||||
this->setHidden(true);
|
||||
}
|
||||
|
||||
void
|
||||
@@ -23,6 +26,12 @@ NotebookPageDropPreview::paintEvent(QPaintEvent *)
|
||||
ColorScheme::getInstance().DropPreviewBackground);
|
||||
}
|
||||
|
||||
void
|
||||
NotebookPageDropPreview::hideEvent(QHideEvent *)
|
||||
{
|
||||
animate = false;
|
||||
}
|
||||
|
||||
void
|
||||
NotebookPageDropPreview::setBounds(const QRect &rect)
|
||||
{
|
||||
@@ -30,13 +39,19 @@ NotebookPageDropPreview::setBounds(const QRect &rect)
|
||||
return;
|
||||
}
|
||||
|
||||
this->positionAnimation.stop();
|
||||
this->positionAnimation.setDuration(50);
|
||||
this->positionAnimation.setStartValue(geometry());
|
||||
this->positionAnimation.setEndValue(rect);
|
||||
this->positionAnimation.start();
|
||||
if (animate) {
|
||||
this->positionAnimation.stop();
|
||||
this->positionAnimation.setDuration(50);
|
||||
this->positionAnimation.setStartValue(this->geometry());
|
||||
this->positionAnimation.setEndValue(rect);
|
||||
this->positionAnimation.start();
|
||||
} else {
|
||||
this->setGeometry(rect);
|
||||
}
|
||||
|
||||
this->desiredGeometry = rect;
|
||||
|
||||
animate = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -17,8 +17,11 @@ public:
|
||||
protected:
|
||||
void paintEvent(QPaintEvent *);
|
||||
|
||||
void hideEvent(QHideEvent *);
|
||||
|
||||
QPropertyAnimation positionAnimation;
|
||||
QRect desiredGeometry;
|
||||
bool animate;
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user