mirror of
https://github.com/Chatterino/chatterino2.git
synced 2024-11-13 19:49:51 +01:00
43 lines
920 B
C++
43 lines
920 B
C++
#include "widgets/notebookpagedroppreview.h"
|
|
#include "colorscheme.h"
|
|
|
|
#include <QPainter>
|
|
|
|
namespace chatterino {
|
|
namespace widgets {
|
|
|
|
NotebookPageDropPreview::NotebookPageDropPreview(QWidget *parent)
|
|
: QWidget(parent)
|
|
, positionAnimation(this, "geometry")
|
|
, desiredGeometry()
|
|
{
|
|
setHidden(true);
|
|
}
|
|
|
|
void
|
|
NotebookPageDropPreview::paintEvent(QPaintEvent *)
|
|
{
|
|
QPainter painter(this);
|
|
|
|
painter.fillRect(8, 8, width() - 17, height() - 17,
|
|
ColorScheme::getInstance().DropPreviewBackground);
|
|
}
|
|
|
|
void
|
|
NotebookPageDropPreview::setBounds(const QRect &rect)
|
|
{
|
|
if (rect == this->desiredGeometry) {
|
|
return;
|
|
}
|
|
|
|
this->positionAnimation.stop();
|
|
this->positionAnimation.setDuration(50);
|
|
this->positionAnimation.setStartValue(geometry());
|
|
this->positionAnimation.setEndValue(rect);
|
|
this->positionAnimation.start();
|
|
|
|
this->desiredGeometry = rect;
|
|
}
|
|
}
|
|
}
|