diff --git a/dde-dock.pro b/dde-dock.pro index f0dc9c0b0..08b696d90 100644 --- a/dde-dock.pro +++ b/dde-dock.pro @@ -3,7 +3,6 @@ TEMPLATE = subdirs SUBDIRS = frame \ plugins - # Automating generation .qm files from .ts files CONFIG(release, debug|release) { !system($$PWD/translate_generation.sh): error("Failed to generate translation") diff --git a/frame/item/components/appsnapshot.cpp b/frame/item/components/appsnapshot.cpp index 9e03e183c..6ce530214 100644 --- a/frame/item/components/appsnapshot.cpp +++ b/frame/item/components/appsnapshot.cpp @@ -55,12 +55,12 @@ AppSnapshot::AppSnapshot(const WId wid, QWidget *parent) setLayout(centralLayout); setAcceptDrops(true); + setFixedSize(SNAP_WIDTH, SNAP_HEIGHT); connect(m_closeBtn, &DImageButton::clicked, this, &AppSnapshot::closeWindow, Qt::QueuedConnection); connect(m_wmHelper, &DWindowManagerHelper::hasCompositeChanged, this, &AppSnapshot::compositeChanged, Qt::QueuedConnection); QTimer::singleShot(1, this, &AppSnapshot::compositeChanged); -// QTimer::singleShot(1, this, &AppSnapshot::fetchSnapshot); } void AppSnapshot::closeWindow() const @@ -147,6 +147,11 @@ void AppSnapshot::fetchSnapshot() m_snapshot = qimage.copy(); } + const auto size = rect().marginsRemoved(QMargins(8, 8, 8, 8)).size(); + const auto ratio = devicePixelRatioF(); + m_snapshot = m_snapshot.scaled(size * ratio, Qt::KeepAspectRatio, Qt::SmoothTransformation); + m_snapshot.setDevicePixelRatio(ratio); + XDestroyImage(ximage); XFree(prop_to_return); @@ -190,8 +195,9 @@ void AppSnapshot::paintEvent(QPaintEvent *e) const auto ratio = devicePixelRatioF(); // draw image - QImage im = m_snapshot.scaled(r.size() * ratio, Qt::KeepAspectRatio, Qt::SmoothTransformation); - im.setDevicePixelRatio(ratio); +// QImage im = m_snapshot.scaled(r.size() * ratio, Qt::KeepAspectRatio, Qt::SmoothTransformation); +// im.setDevicePixelRatio(ratio); + const QImage &im = m_snapshot; const QRect ir = im.rect(); const int offset_x = r.x() + r.width() / 2 - ir.width() / ratio / 2; diff --git a/frame/item/components/appsnapshot.h b/frame/item/components/appsnapshot.h index 2bda9a827..cd0db0a64 100644 --- a/frame/item/components/appsnapshot.h +++ b/frame/item/components/appsnapshot.h @@ -32,6 +32,9 @@ DWIDGET_USE_NAMESPACE +#define SNAP_WIDTH 200 +#define SNAP_HEIGHT 130 + class AppSnapshot : public QWidget { Q_OBJECT diff --git a/frame/item/components/previewcontainer.h b/frame/item/components/previewcontainer.h index 39e97c861..d6ee181cf 100644 --- a/frame/item/components/previewcontainer.h +++ b/frame/item/components/previewcontainer.h @@ -33,9 +33,6 @@ #include -#define SNAP_WIDTH 200 -#define SNAP_HEIGHT 130 - DWIDGET_USE_NAMESPACE class PreviewContainer : public QWidget