|
31 | 31 |
|
32 | 32 | #include <DStyle> |
33 | 33 | #include <DPlatformHandle> |
| 34 | +#include <QDBusReply> |
34 | 35 |
|
35 | 36 | #include <DWindowManagerHelper> |
36 | 37 | #include <DGuiApplicationHelper> |
| 38 | +#include <appletbridge.h> |
37 | 39 |
|
38 | 40 | Q_LOGGING_CATEGORY(x11WindowPreview, "dde.shell.dock.taskmanager.x11WindowPreview") |
39 | 41 |
|
@@ -401,6 +403,7 @@ X11WindowPreviewContainer::X11WindowPreviewContainer(X11WindowMonitor* monitor, |
401 | 403 | , m_isDockPreviewCount(0) |
402 | 404 | , m_model(new AppItemWindowModel(this)) |
403 | 405 | , m_titleWidget(new QWidget()) |
| 406 | + , m_systemOpacity(0.2) |
404 | 407 | { |
405 | 408 | m_hideTimer = new QTimer(this); |
406 | 409 | m_hideTimer->setSingleShot(true); |
@@ -518,6 +521,33 @@ void X11WindowPreviewContainer::resizeEvent(QResizeEvent *event) |
518 | 521 | updatePosition(); |
519 | 522 | } |
520 | 523 |
|
| 524 | +void X11WindowPreviewContainer::paintEvent(QPaintEvent *event) |
| 525 | +{ |
| 526 | + Q_UNUSED(event) |
| 527 | + |
| 528 | + QPainter painter(this); |
| 529 | + painter.setRenderHint(QPainter::Antialiasing); |
| 530 | + |
| 531 | + QColor backgroundColor; |
| 532 | + |
| 533 | + auto themeType = DGuiApplicationHelper::instance()->themeType(); |
| 534 | + if (themeType == DGuiApplicationHelper::DarkType) { |
| 535 | + backgroundColor = QColor(0, 0, 0, static_cast<int>(255 * m_systemOpacity)); |
| 536 | + } else { |
| 537 | + backgroundColor = QColor(255, 255, 255, static_cast<int>(255 * m_systemOpacity)); |
| 538 | + } |
| 539 | + |
| 540 | + painter.setBrush(backgroundColor); |
| 541 | + painter.setPen(Qt::NoPen); |
| 542 | + |
| 543 | + // 获取圆角半径 |
| 544 | + DStyleHelper dstyle(style()); |
| 545 | + const int radius = dstyle.pixelMetric(DStyle::PM_FrameRadius); |
| 546 | + |
| 547 | + // 绘制带圆角的背景 |
| 548 | + painter.drawRoundedRect(rect(), radius, radius); |
| 549 | +} |
| 550 | + |
521 | 551 | void X11WindowPreviewContainer::updatePosition() |
522 | 552 | { |
523 | 553 | auto screenRect = m_baseWindow->screen()->geometry(); |
@@ -754,4 +784,16 @@ void X11WindowPreviewContainer::updatePreviewIconFromBase64(const QString &base6 |
754 | 784 | m_previewIcon->setPixmap(QIcon::fromTheme(m_previewItem->icon()).pixmap(PREVIEW_TITLE_HEIGHT, PREVIEW_TITLE_HEIGHT)); |
755 | 785 | } |
756 | 786 | } |
| 787 | + |
| 788 | +double X11WindowPreviewContainer::getOpacity() const |
| 789 | +{ |
| 790 | + return m_systemOpacity; |
| 791 | +} |
| 792 | + |
| 793 | +void X11WindowPreviewContainer::setOpacity(double opacity) |
| 794 | +{ |
| 795 | + m_systemOpacity = opacity; |
| 796 | + update(); |
| 797 | +} |
| 798 | + |
757 | 799 | } |
0 commit comments