2017-11-12 17:21:50 +01:00
|
|
|
#include "widgets/helper/droppreview.hpp"
|
2017-12-31 00:50:07 +01:00
|
|
|
#include "singletons/thememanager.hpp"
|
2017-01-01 02:30:42 +01:00
|
|
|
|
2017-01-26 09:26:18 +01:00
|
|
|
#include <QDebug>
|
2017-01-18 04:52:47 +01:00
|
|
|
#include <QPainter>
|
|
|
|
|
2017-04-14 17:52:22 +02:00
|
|
|
namespace chatterino {
|
|
|
|
namespace widgets {
|
2017-01-18 21:30:23 +01:00
|
|
|
|
2017-06-26 16:41:20 +02:00
|
|
|
NotebookPageDropPreview::NotebookPageDropPreview(BaseWidget *parent)
|
|
|
|
: BaseWidget(parent)
|
2017-01-18 04:33:30 +01:00
|
|
|
, positionAnimation(this, "geometry")
|
2017-01-01 02:30:42 +01:00
|
|
|
{
|
2017-01-26 09:26:18 +01:00
|
|
|
this->positionAnimation.setEasingCurve(QEasingCurve(QEasingCurve::InCubic));
|
|
|
|
this->setHidden(true);
|
2017-01-01 02:30:42 +01:00
|
|
|
}
|
|
|
|
|
2017-04-12 17:46:44 +02:00
|
|
|
void NotebookPageDropPreview::paintEvent(QPaintEvent *)
|
2017-01-01 02:30:42 +01:00
|
|
|
{
|
|
|
|
QPainter painter(this);
|
|
|
|
|
2017-07-02 14:28:37 +02:00
|
|
|
painter.fillRect(8, 8, this->width() - 17, this->height() - 17,
|
2017-12-31 00:50:07 +01:00
|
|
|
this->themeManager.DropPreviewBackground);
|
2017-01-01 02:30:42 +01:00
|
|
|
}
|
2017-01-16 17:20:48 +01:00
|
|
|
|
2017-04-12 17:46:44 +02:00
|
|
|
void NotebookPageDropPreview::hideEvent(QHideEvent *)
|
2017-01-26 09:26:18 +01:00
|
|
|
{
|
2017-06-26 16:41:20 +02:00
|
|
|
this->animate = false;
|
2017-01-26 09:26:18 +01:00
|
|
|
}
|
|
|
|
|
2017-04-12 17:46:44 +02:00
|
|
|
void NotebookPageDropPreview::setBounds(const QRect &rect)
|
2017-01-16 17:20:48 +01:00
|
|
|
{
|
2017-01-18 04:33:30 +01:00
|
|
|
if (rect == this->desiredGeometry) {
|
2017-01-16 17:20:48 +01:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2017-06-26 16:41:20 +02:00
|
|
|
if (this->animate) {
|
2017-01-26 09:26:18 +01:00
|
|
|
this->positionAnimation.stop();
|
|
|
|
this->positionAnimation.setDuration(50);
|
|
|
|
this->positionAnimation.setStartValue(this->geometry());
|
|
|
|
this->positionAnimation.setEndValue(rect);
|
|
|
|
this->positionAnimation.start();
|
|
|
|
} else {
|
|
|
|
this->setGeometry(rect);
|
|
|
|
}
|
2017-01-16 17:20:48 +01:00
|
|
|
|
2017-01-18 04:33:30 +01:00
|
|
|
this->desiredGeometry = rect;
|
2017-01-26 09:26:18 +01:00
|
|
|
|
2017-06-26 16:41:20 +02:00
|
|
|
this->animate = true;
|
2017-01-16 17:20:48 +01:00
|
|
|
}
|
2017-06-07 10:09:24 +02:00
|
|
|
|
|
|
|
} // namespace widgets
|
|
|
|
} // namespace chatterino
|