add preview popup

Change-Id: Ia84daa0ed1543a32445f7bbac80a6af65188c3c5
This commit is contained in:
石博文 2017-04-18 10:20:06 +08:00
parent 42610aec46
commit 1a008a27f0
Notes: Deepin Code Review 2017-04-18 10:52:05 +08:00
Verified+1: Anonymous Coward #1000004
Code-Review+2: 石博文 <sbw@sbw.so>
Submitted-by: 石博文 <sbw@sbw.so>
Submitted-at: Tue, 18 Apr 2017 10:52:04 +0800
Reviewed-on: https://cr.deepin.io/22382
Project: dde/dde-dock
Branch: refs/heads/master
3 changed files with 5 additions and 10 deletions

View File

@ -256,15 +256,11 @@ void AppItem::mouseReleaseEvent(QMouseEvent *e)
// if (distance.manhattanLength() > APP_DRAG_THRESHOLD)
// return;
#ifdef QT_DEBUG
const int windowCount = m_titles.size();
if (windowCount < 2)
m_itemEntry->Activate();
else
togglePreview();
#else
m_itemEntry->Activate();
#endif
// if (!m_titles.isEmpty())
// return;

View File

@ -5,7 +5,6 @@
#include <X11/Xutil.h>
#include <QX11Info>
#include <QPainter>
#include <QTimer>
@ -27,12 +26,12 @@ void PreviewWidget::refershImage()
XWindowAttributes attrs;
XGetWindowAttributes(QX11Info::display(), m_wid, &attrs);
XImage *ximage = XGetImage(QX11Info::display(), m_wid, 0, 0, attrs.width, attrs.height, AllPlanes, ZPixmap);
const QImage qimage((uchar*)(ximage->data), attrs.width, attrs.height, QImage::Format_ARGB32);
XDestroyImage(ximage);
m_pixmap = QPixmap::fromImage(qimage).scaled(W, H, Qt::KeepAspectRatio, Qt::SmoothTransformation);
const QImage qimage((const uchar*)(ximage->data), ximage->width, ximage->height, ximage->bytes_per_line, QImage::Format_ARGB32_Premultiplied);
m_image = qimage.scaled(W, H, Qt::KeepAspectRatio, Qt::SmoothTransformation);
update();
XDestroyImage(ximage);
}
void PreviewWidget::paintEvent(QPaintEvent *e)
@ -40,7 +39,7 @@ void PreviewWidget::paintEvent(QPaintEvent *e)
QWidget::paintEvent(e);
QPainter painter(this);
painter.drawPixmap(rect().center() - m_pixmap.rect().center(), m_pixmap);
painter.drawImage(rect().center() - m_image.rect().center(), m_image);
}
void PreviewWidget::mouseReleaseEvent(QMouseEvent *e)

View File

@ -21,7 +21,7 @@ private:
private:
const WId m_wid;
QPixmap m_pixmap;
QImage m_image;
};
#endif // PREVIEWWIDGET_H