mirror of
https://github.com/linuxdeepin/dde-dock.git
synced 2025-06-03 00:15:21 +00:00
fix preview window size error
Change-Id: I0632673eb4b77579ef0eb74849e32e1f175e9d87
This commit is contained in:
parent
1ad9ac4c8d
commit
32253abbc0
Notes:
Deepin Code Review
2017-05-02 20:30:51 +08:00
Verified+1: Anonymous Coward #1000004 Code-Review+2: 石博文 <sbw@sbw.so> Submitted-by: 石博文 <sbw@sbw.so> Submitted-at: Tue, 02 May 2017 20:30:49 +0800 Reviewed-on: https://cr.deepin.io/22748 Project: dde/dde-dock Branch: refs/heads/master
@ -451,6 +451,7 @@ void AppItem::updateTitle()
|
||||
{
|
||||
m_titles = m_itemEntry->titles();
|
||||
|
||||
// TODO: optimize
|
||||
m_appPreviewTips->setWindowInfos(m_titles);
|
||||
|
||||
update();
|
||||
@ -496,7 +497,8 @@ void AppItem::showPreview()
|
||||
}
|
||||
|
||||
m_appPreviewTips->updateLayoutDirection(DockPosition);
|
||||
// m_appPreviewTips->setWindowInfos(m_titles);
|
||||
|
||||
qApp->processEvents();
|
||||
|
||||
showPopupWindow(m_appPreviewTips, true);
|
||||
}
|
||||
|
@ -37,6 +37,12 @@ void PreviewContainer::setWindowInfos(const WindowDict &infos)
|
||||
|
||||
m_windowListLayout->addWidget(w);
|
||||
}
|
||||
|
||||
if (!isVisible())
|
||||
return;
|
||||
|
||||
// update geometry
|
||||
QMetaObject::invokeMethod(this, "updateContainerSize", Qt::QueuedConnection);
|
||||
}
|
||||
|
||||
void PreviewContainer::updateLayoutDirection(const Dock::Position dockPos)
|
||||
@ -64,3 +70,8 @@ void PreviewContainer::leaveEvent(QEvent *e)
|
||||
if (!rect().contains(p))
|
||||
emit requestCancelPreview();
|
||||
}
|
||||
|
||||
void PreviewContainer::updateContainerSize()
|
||||
{
|
||||
resize(sizeHint());
|
||||
}
|
||||
|
@ -29,6 +29,9 @@ public slots:
|
||||
protected:
|
||||
void leaveEvent(QEvent *e);
|
||||
|
||||
private slots:
|
||||
void updateContainerSize();
|
||||
|
||||
private:
|
||||
QBoxLayout *m_windowListLayout;
|
||||
};
|
||||
|
@ -9,9 +9,9 @@
|
||||
#include <QTimer>
|
||||
#include <QVBoxLayout>
|
||||
|
||||
#define W 200
|
||||
#define H 130
|
||||
#define M 8
|
||||
#define PREVIEW_W 200
|
||||
#define PREVIEW_H 130
|
||||
#define PREVIEW_M 8
|
||||
|
||||
PreviewWidget::PreviewWidget(const WId wid, QWidget *parent)
|
||||
: QWidget(parent),
|
||||
@ -34,7 +34,7 @@ PreviewWidget::PreviewWidget(const WId wid, QWidget *parent)
|
||||
centralLayout->addWidget(m_closeButton);
|
||||
centralLayout->setAlignment(m_closeButton, Qt::AlignTop | Qt::AlignRight);
|
||||
|
||||
setFixedSize(W + M * 2, H + M * 2);
|
||||
setFixedSize(PREVIEW_W + PREVIEW_M * 2, PREVIEW_H + PREVIEW_M * 2);
|
||||
setLayout(centralLayout);
|
||||
setAcceptDrops(true);
|
||||
|
||||
@ -57,8 +57,8 @@ void PreviewWidget::refershImage()
|
||||
XImage *ximage = XGetImage(display, m_wid, 0, 0, attrs.width, attrs.height, AllPlanes, ZPixmap);
|
||||
|
||||
const QImage qimage((const uchar*)(ximage->data), ximage->width, ximage->height, ximage->bytes_per_line, QImage::Format_RGB32);
|
||||
m_image = qimage.scaled(W, H, Qt::KeepAspectRatioByExpanding, Qt::SmoothTransformation);
|
||||
m_image = m_image.copy((m_image.width() - W) / 2, (m_image.height() - H) / 2, W, H);
|
||||
m_image = qimage.scaled(PREVIEW_W, PREVIEW_H, Qt::KeepAspectRatioByExpanding, Qt::SmoothTransformation);
|
||||
m_image = m_image.copy((m_image.width() - PREVIEW_W) / 2, (m_image.height() - PREVIEW_H) / 2, PREVIEW_W, PREVIEW_H);
|
||||
XDestroyImage(ximage);
|
||||
|
||||
update();
|
||||
@ -93,7 +93,7 @@ void PreviewWidget::setVisible(const bool visible)
|
||||
|
||||
void PreviewWidget::paintEvent(QPaintEvent *e)
|
||||
{
|
||||
const QRect r = rect().marginsRemoved(QMargins(M, M, M, M));
|
||||
const QRect r = rect().marginsRemoved(QMargins(PREVIEW_M, PREVIEW_M, PREVIEW_M, PREVIEW_M));
|
||||
|
||||
QPainter painter(this);
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user