fixed notebookpagedroppreview animation

This commit is contained in:
fourtf
2017-01-26 09:26:18 +01:00
parent d012aa922d
commit a5e7ef9980
5 changed files with 54 additions and 30 deletions
+1 -1
View File
@@ -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();
+21 -6
View File
@@ -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;
}
}
}
+3
View File
@@ -17,8 +17,11 @@ public:
protected:
void paintEvent(QPaintEvent *);
void hideEvent(QHideEvent *);
QPropertyAnimation positionAnimation;
QRect desiredGeometry;
bool animate;
};
}
}