Skip to content

Commit

Permalink
sync: from linuxdeepin/dtkwidget
Browse files Browse the repository at this point in the history
Synchronize source files from linuxdeepin/dtkwidget.

Source-pull-request: linuxdeepin/dtkwidget#559
  • Loading branch information
deepin-ci-robot committed Mar 22, 2024
1 parent 4f9e22b commit 7409f30
Show file tree
Hide file tree
Showing 9 changed files with 16 additions and 40 deletions.
1 change: 1 addition & 0 deletions include/widgets/dstyle.h
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@ void drawIndicatorChecked(QPainter *pa, const QRectF &rect);
void drawDeleteButton(QPainter *pa, const QRectF &rect);
void drawAddButton(QPainter *pa, const QRectF &rect);

void drawTitleBarIcon(QPainter *pa, const QRectF &rect, const QString &iconName);
void drawTitleBarMenuButton(QPainter *pa, const QRectF &rect);
void drawTitleBarMinButton(QPainter *pa, const QRectF &rect);
void drawTitleBarMaxButton(QPainter *pa, const QRectF &rect);
Expand Down
Binary file added src/widgets/assets/icons/bloom/window_close.dci
Binary file not shown.
Binary file added src/widgets/assets/icons/bloom/window_maximize.dci
Binary file not shown.
Binary file modified src/widgets/assets/icons/bloom/window_menu.dci
Binary file not shown.
Binary file added src/widgets/assets/icons/bloom/window_minimize.dci
Binary file not shown.
Binary file added src/widgets/assets/icons/bloom/window_normal.dci
Binary file not shown.
4 changes: 4 additions & 0 deletions src/widgets/assets/icons/dtk-icon-theme.qrc
Original file line number Diff line number Diff line change
Expand Up @@ -68,5 +68,9 @@
<file alias="play_pause.dci">bloom/play_pause.dci</file>
<file alias="play_previous.dci">bloom/play_previous.dci</file>
<file alias="play_next.dci">bloom/play_next.dci</file>
<file alias="window_close.dci">bloom/window_close.dci</file>
<file alias="window_maximize.dci">bloom/window_maximize.dci</file>
<file alias="window_minimize.dci">bloom/window_minimize.dci</file>
<file alias="window_normal.dci">bloom/window_normal.dci</file>
</qresource>
</RCC>
3 changes: 0 additions & 3 deletions src/widgets/dalertcontrol.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -282,9 +282,6 @@ bool DAlertControl::eventFilter(QObject *watched, QEvent *event)
if (watched == d->follower) {
if (event->type() == QEvent::Move || event->type() == QEvent::Resize)
d->updateTooltipPos();

if (event->type() == QEvent::Hide || event->type() == QEvent::HideToParent)
hideAlertMessage();
}

if (d->follower && watched == d->follower->topLevelWidget()) {
Expand Down
48 changes: 11 additions & 37 deletions src/widgets/dstyle.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -696,7 +696,7 @@ void drawAddButton(QPainter *pa, const QRectF &rect)
pa->fillPath(path, QColor("#48bf00"));
}

void drawTitleBarMenuButton(QPainter *pa, const QRectF &rect)
void drawTitleBarIcon(QPainter *pa, const QRectF &rect, const QString &iconName)
{
const QPen pen = pa->pen();
pa->setPen(Qt::NoPen);
Expand All @@ -705,7 +705,7 @@ void drawTitleBarMenuButton(QPainter *pa, const QRectF &rect)
content_rect.moveCenter(rect.center().toPoint());
pa->setPen(pen);

const DDciIcon &icon = DDciIcon::fromTheme(QLatin1String("window_menu"));
const DDciIcon &icon = DDciIcon::fromTheme(iconName);
auto devicePixelRatio = pa->device() ? pa->device()->devicePixelRatioF()
: qApp->devicePixelRatio();
auto appTheme = DGuiApplicationHelper::toColorType(pa->pen().color());
Expand All @@ -714,55 +714,29 @@ void drawTitleBarMenuButton(QPainter *pa, const QRectF &rect)
icon.paint(pa, rect.toRect(), devicePixelRatio, theme, DDciIcon::Normal, Qt::AlignCenter, palette);
}

void drawTitleBarMenuButton(QPainter *pa, const QRectF &rect)
{
drawTitleBarIcon(pa, rect, QLatin1String("window_menu"));
}

void drawTitleBarMinButton(QPainter *pa, const QRectF &rect)
{
const QPen pen = pa->pen();
pa->setPen(Qt::NoPen);
pa->drawRect(rect);
QRect content_rect(0, 0, rect.width() / 5, rect.height() / 5);
content_rect.moveCenter(rect.center().toPoint());
pa->setPen(pen);
pa->setRenderHint(QPainter::Antialiasing, pa->device()->devicePixelRatioF() > 1.0);
drawDecreaseElement(pa, content_rect);
drawTitleBarIcon(pa, rect, QLatin1String("window_minimize"));
}

void drawTitleBarMaxButton(QPainter *pa, const QRectF &rect)
{
const QPen pen = pa->pen();
pa->setPen(Qt::NoPen);
pa->drawRect(rect);
QRect content_rect(0, 0, rect.width() / 5, rect.height() / 6);
content_rect.moveCenter(rect.center().toPoint());
pa->setPen(pen);
pa->setRenderHint(QPainter::Antialiasing, pa->device()->devicePixelRatioF() > 1.0);
pa->drawRect(content_rect);
drawTitleBarIcon(pa, rect, QLatin1String("window_maximize"));
}

void drawTitleBarCloseButton(QPainter *pa, const QRectF &rect)
{
const QPen pen = pa->pen();
pa->setPen(Qt::NoPen);
pa->drawRect(rect);
QRectF content_rect(0, 0, rect.width() / 5, rect.height() / 5);
content_rect.moveCenter(rect.center());
pa->setPen(pen);
pa->setRenderHint(QPainter::Antialiasing, pa->device()->devicePixelRatioF() > 1.0);
drawForkElement(pa, content_rect);
drawTitleBarIcon(pa, rect, QLatin1String("window_close"));
}

void drawTitleBarNormalButton(QPainter *pa, const QRectF &rect)
{
const QPen pen = pa->pen();
pa->setPen(Qt::NoPen);
pa->drawRect(rect);
QRect content_rect(0, 0, rect.width() / 5, rect.height() / 5);
content_rect.moveCenter(rect.center().toPoint());
pa->setPen(pen);

pa->setRenderHint(QPainter::Antialiasing, pa->device()->devicePixelRatioF() > 1.0);
pa->drawRect(content_rect.x(), content_rect.y() + 2, content_rect.width() - 2, content_rect.height() - 2);
pa->drawLine(content_rect.x() + 2, content_rect.y(), content_rect.right(), content_rect.y());
pa->drawLine(content_rect.right() + 1, content_rect.y(), content_rect.right() + 1, content_rect.bottom() - 2);
drawTitleBarIcon(pa, rect, QLatin1String("window_normal"));
}

void drawTitleQuitFullButton(QPainter *pa, const QRectF &rect)
Expand Down

0 comments on commit 7409f30

Please sign in to comment.