mirror of
https://github.com/linuxdeepin/dde-dock.git
synced 2025-06-03 00:15:21 +00:00
drawRoundedRect add scale
This commit is contained in:
parent
eced298591
commit
8590b4ae86
@ -239,8 +239,8 @@ void AppSnapshot::paintEvent(QPaintEvent *e)
|
||||
// draw image
|
||||
const QImage &im = m_snapshot;
|
||||
|
||||
const qreal offset_x = width() / 2.0 - m_snapshotSrcRect.width() / ratio / 2 - m_snapshotSrcRect.left();
|
||||
const qreal offset_y = height() / 2.0 - m_snapshotSrcRect.height() / ratio / 2 - m_snapshotSrcRect.top();
|
||||
const qreal offset_x = width() / 2.0 - m_snapshotSrcRect.width() / ratio / 2 - m_snapshotSrcRect.left() / ratio;
|
||||
const qreal offset_y = height() / 2.0 - m_snapshotSrcRect.height() / ratio / 2 - m_snapshotSrcRect.top() / ratio;
|
||||
|
||||
DStyleHelper dstyle(style());
|
||||
const int radius = dstyle.pixelMetric(DStyle::PM_FrameRadius);
|
||||
@ -249,8 +249,9 @@ void AppSnapshot::paintEvent(QPaintEvent *e)
|
||||
brush.setTextureImage(im);
|
||||
painter.setBrush(brush);
|
||||
painter.setPen(Qt::NoPen);
|
||||
painter.translate(QPoint(offset_x, offset_y));
|
||||
painter.drawRoundedRect(m_snapshotSrcRect, radius, radius);
|
||||
painter.scale(1 / ratio, 1 / ratio);
|
||||
painter.translate(QPoint(offset_x * ratio, offset_y * ratio));
|
||||
painter.drawRoundedRect(m_snapshotSrcRect, radius * ratio, radius * ratio);
|
||||
}
|
||||
|
||||
void AppSnapshot::resizeEvent(QResizeEvent *e)
|
||||
|
@ -119,8 +119,8 @@ void FloatingPreview::paintEvent(QPaintEvent *e)
|
||||
const QRectF r = rect().marginsRemoved(QMargins(BORDER_MARGIN, BORDER_MARGIN, BORDER_MARGIN, BORDER_MARGIN));
|
||||
const auto ratio = devicePixelRatioF();
|
||||
|
||||
const qreal offset_x = width() / 2.0 - snapshot_geometry.width() / ratio / 2 - snapshot_geometry.left();
|
||||
const qreal offset_y = height() / 2.0 - snapshot_geometry.height() / ratio / 2 - snapshot_geometry.top();
|
||||
const qreal offset_x = width() / 2.0 - snapshot_geometry.width() / ratio / 2 - snapshot_geometry.left() / ratio;
|
||||
const qreal offset_y = height() / 2.0 - snapshot_geometry.height() / ratio / 2 - snapshot_geometry.top() / ratio;
|
||||
|
||||
DStyleHelper dstyle(style());
|
||||
const int radius = dstyle.pixelMetric(DStyle::PM_FrameRadius);
|
||||
@ -130,9 +130,11 @@ void FloatingPreview::paintEvent(QPaintEvent *e)
|
||||
brush.setTextureImage(snapshot);
|
||||
painter.setBrush(brush);
|
||||
painter.setPen(Qt::NoPen);
|
||||
painter.translate(QPoint(offset_x, offset_y));
|
||||
painter.drawRoundedRect(snapshot_geometry, radius, radius);
|
||||
painter.translate(QPoint(-offset_x, -offset_y));
|
||||
painter.scale(1 / ratio, 1 / ratio);
|
||||
painter.translate(QPoint(offset_x * ratio, offset_y * ratio));
|
||||
painter.drawRoundedRect(snapshot_geometry, radius * ratio, radius * ratio);
|
||||
painter.translate(QPoint(-offset_x * ratio, -offset_y * ratio));
|
||||
painter.scale(ratio, ratio);
|
||||
|
||||
// 选中外框
|
||||
QPen pen;
|
||||
|
@ -115,7 +115,6 @@ void PopupControlWidget::clearTrashFloder()
|
||||
d.addButton(buttonTexts[0], true, DDialog::ButtonNormal);
|
||||
d.addButton(buttonTexts[1], false, DDialog::ButtonWarning);
|
||||
d.setDefaultButton(1);
|
||||
d.getButton(1)->setFocus();
|
||||
d.moveToCenter();
|
||||
execCode = d.exec();
|
||||
}
|
||||
|
@ -30,8 +30,6 @@
|
||||
#include <QWidget>
|
||||
#include <QFileSystemWatcher>
|
||||
|
||||
#include <dlinkbutton.h>
|
||||
|
||||
class PopupControlWidget : public QWidget
|
||||
{
|
||||
Q_OBJECT
|
||||
|
@ -34,8 +34,6 @@
|
||||
#include <QJsonDocument>
|
||||
#include <QApplication>
|
||||
|
||||
DWIDGET_USE_NAMESPACE
|
||||
|
||||
TrashWidget::TrashWidget(QWidget *parent)
|
||||
: QWidget(parent),
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user