2017-01-01 02:30:42 +01:00
|
|
|
#include "notebookpagedroppreview.h"
|
|
|
|
#include "QPainter"
|
|
|
|
#include "colorscheme.h"
|
|
|
|
|
2017-01-15 17:13:25 +01:00
|
|
|
NotebookPageDropPreview::NotebookPageDropPreview(QWidget *parent)
|
2017-01-01 02:30:42 +01:00
|
|
|
: QWidget(parent)
|
2017-01-16 17:20:48 +01:00
|
|
|
, m_positionAnimation(this, "geometry")
|
|
|
|
, m_desiredGeometry()
|
2017-01-01 02:30:42 +01:00
|
|
|
{
|
2017-01-01 13:07:36 +01:00
|
|
|
setHidden(true);
|
2017-01-01 02:30:42 +01:00
|
|
|
}
|
|
|
|
|
2017-01-11 18:52:09 +01:00
|
|
|
void
|
|
|
|
NotebookPageDropPreview::paintEvent(QPaintEvent *)
|
2017-01-01 02:30:42 +01:00
|
|
|
{
|
|
|
|
QPainter painter(this);
|
|
|
|
|
2017-01-11 18:52:09 +01:00
|
|
|
painter.fillRect(8, 8, width() - 17, height() - 17,
|
|
|
|
ColorScheme::instance().DropPreviewBackground);
|
2017-01-01 02:30:42 +01:00
|
|
|
}
|
2017-01-16 17:20:48 +01:00
|
|
|
|
|
|
|
void
|
|
|
|
NotebookPageDropPreview::setBounds(const QRect &rect)
|
|
|
|
{
|
|
|
|
if (rect == m_desiredGeometry) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
m_positionAnimation.stop();
|
|
|
|
m_positionAnimation.setDuration(50);
|
|
|
|
m_positionAnimation.setStartValue(geometry());
|
|
|
|
m_positionAnimation.setEndValue(rect);
|
|
|
|
m_positionAnimation.start();
|
|
|
|
|
|
|
|
m_desiredGeometry = rect;
|
|
|
|
}
|