From bb9d58096f107fa654e27e9c9822cefc589a6bbd Mon Sep 17 00:00:00 2001 From: shaojun Date: Thu, 14 Nov 2019 10:34:50 +0800 Subject: [PATCH] feat:efficient mode app active status --- frame/item/appitem.cpp | 33 +++++++++++++-------------------- 1 file changed, 13 insertions(+), 20 deletions(-) diff --git a/frame/item/appitem.cpp b/frame/item/appitem.cpp index 320f0ed93..35ddf4050 100644 --- a/frame/item/appitem.cpp +++ b/frame/item/appitem.cpp @@ -208,40 +208,33 @@ void AppItem::paintEvent(QPaintEvent *e) const QRectF itemRect = rect(); - // draw background - QRectF backgroundRect = itemRect; - if (DockDisplayMode == Efficient) { - backgroundRect = itemRect.marginsRemoved(QMargins(1, 1, 1, 1)); + // draw background + qreal min = qMin(itemRect.width(), itemRect.height()); + QRectF backgroundRect = QRectF(itemRect.x(), itemRect.y(), min, min); + backgroundRect = backgroundRect.marginsRemoved(QMargins(2, 2, 2, 2)); + backgroundRect.moveCenter(itemRect.center()); + + QPainterPath path; + path.addRoundedRect(backgroundRect, 8, 8); if (m_active) { - painter.fillRect(backgroundRect, QColor(44, 167, 248, 255 * 0.3)); - - const int activeLineWidth = itemRect.height() > 50 ? 4 : 2; - QRectF activeRect = backgroundRect; - switch (DockPosition) { - case Top: activeRect.setBottom(activeRect.top() + activeLineWidth); break; - case Bottom: activeRect.setTop(activeRect.bottom() - activeLineWidth); break; - case Left: activeRect.setRight(activeRect.left() + activeLineWidth); break; - case Right: activeRect.setLeft(activeRect.right() - activeLineWidth); break; - } - - painter.fillRect(activeRect, QColor(44, 167, 248, 255)); + painter.fillPath(path, QColor(0, 0, 0, 255 * 0.8)); } else if (!m_windowInfos.isEmpty()) { if (hasAttention()) - painter.fillRect(backgroundRect, QColor(241, 138, 46, 255 * .8)); + painter.fillPath(path, QColor(241, 138, 46, 255 * .8)); else - painter.fillRect(backgroundRect, QColor(255, 255, 255, 255 * 0.2)); + painter.fillPath(path, QColor(0, 0, 0, 255 * 0.3)); } } else { if (!m_windowInfos.isEmpty()) { QPoint p; QPixmap pixmap; QPixmap activePixmap; - if(DGuiApplicationHelper::DarkType == m_themeType){ + if (DGuiApplicationHelper::DarkType == m_themeType) { m_horizontalIndicator = QPixmap(":/indicator/resources/indicator_dark.svg"); m_verticalIndicator = QPixmap(":/indicator/resources/indicator_dark_ver.svg"); - }else { + } else { m_horizontalIndicator = QPixmap(":/indicator/resources/indicator.svg"); m_verticalIndicator = QPixmap(":/indicator/resources/indicator_ver.svg"); }