mirror of
https://github.com/Chatterino/chatterino2.git
synced 2024-11-13 19:49:51 +01:00
added animation to NotebookPageDropPreview
This commit is contained in:
parent
d7f98030e1
commit
7901071408
|
@ -175,8 +175,10 @@ NotebookPage::setPreviewRect(QPoint mousePos)
|
|||
{
|
||||
for (DropRegion region : m_dropRegions) {
|
||||
if (region.rect.contains(mousePos)) {
|
||||
m_preview.move(region.rect.x(), region.rect.y());
|
||||
m_preview.resize(region.rect.width(), region.rect.height());
|
||||
m_preview.setBounds(region.rect);
|
||||
// m_preview.move(region.rect.x(), region.rect.y());
|
||||
// m_preview.resize(region.rect.width(),
|
||||
// region.rect.height());
|
||||
m_preview.show();
|
||||
m_preview.raise();
|
||||
|
||||
|
|
|
@ -4,6 +4,8 @@
|
|||
|
||||
NotebookPageDropPreview::NotebookPageDropPreview(QWidget *parent)
|
||||
: QWidget(parent)
|
||||
, m_positionAnimation(this, "geometry")
|
||||
, m_desiredGeometry()
|
||||
{
|
||||
setHidden(true);
|
||||
}
|
||||
|
@ -16,3 +18,19 @@ NotebookPageDropPreview::paintEvent(QPaintEvent *)
|
|||
painter.fillRect(8, 8, width() - 17, height() - 17,
|
||||
ColorScheme::instance().DropPreviewBackground);
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
#ifndef NOTEBOOKPAGEDROPPREVIEW_H
|
||||
#define NOTEBOOKPAGEDROPPREVIEW_H
|
||||
|
||||
#include <QPropertyAnimation>
|
||||
#include <QWidget>
|
||||
|
||||
class NotebookPageDropPreview : public QWidget
|
||||
|
@ -8,8 +9,13 @@ class NotebookPageDropPreview : public QWidget
|
|||
public:
|
||||
NotebookPageDropPreview(QWidget *parent);
|
||||
|
||||
void setBounds(const QRect &rect);
|
||||
|
||||
protected:
|
||||
void paintEvent(QPaintEvent *);
|
||||
|
||||
QPropertyAnimation m_positionAnimation;
|
||||
QRect m_desiredGeometry;
|
||||
};
|
||||
|
||||
#endif // NOTEBOOKPAGEDROPPREVIEW_H
|
||||
|
|
Loading…
Reference in a new issue