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#561
  • Loading branch information
deepin-ci-robot committed Apr 1, 2024
1 parent 4f9e22b commit 94be06f
Show file tree
Hide file tree
Showing 10 changed files with 22 additions and 47 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
13 changes: 6 additions & 7 deletions src/widgets/dstyleditemdelegate.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -267,13 +267,13 @@ class DStyledItemDelegatePrivate : public DCORE_NAMESPACE::DObjectPrivate

if (action->alignment().testFlag(Qt::AlignVCenter)) {
result_list << QStyle::alignedRect(direction, action->alignment(), size_list.at(i), center_rect);
center_rect.setLeft(result_list.last().right() + spacing);
center_rect.setLeft(result_list.last().right() + spacing + 1);
} else if (action->alignment().testFlag(Qt::AlignBottom)) {
result_list << QStyle::alignedRect(direction, action->alignment(), size_list.at(i), bottom_rect);
bottom_rect.setLeft(result_list.last().right() + spacing);
bottom_rect.setLeft(result_list.last().right() + spacing + 1);
} else {
result_list << QStyle::alignedRect(direction, action->alignment(), size_list.at(i), top_rect);
top_rect.setLeft(result_list.last().right() + spacing);
top_rect.setLeft(result_list.last().right() + spacing + 1);
}

if (bounding)
Expand Down Expand Up @@ -311,13 +311,13 @@ class DStyledItemDelegatePrivate : public DCORE_NAMESPACE::DObjectPrivate

if (action->alignment().testFlag(Qt::AlignHCenter)) {
result_list << QStyle::alignedRect(direction, action->alignment(), size_list.at(i), center_rect);
center_rect.setTop(result_list.last().bottom() + spacing);
center_rect.setTop(result_list.last().bottom() + spacing + 1);
} else if (action->alignment().testFlag(Qt::AlignRight)) {
result_list << QStyle::alignedRect(direction, action->alignment(), size_list.at(i), right_rect);
right_rect.setTop(result_list.last().bottom() + spacing);
right_rect.setTop(result_list.last().bottom() + spacing + 1);
} else {
result_list << QStyle::alignedRect(direction, action->alignment(), size_list.at(i), left_rect);
left_rect.setTop(result_list.last().bottom() + spacing);
left_rect.setTop(result_list.last().bottom() + spacing + 1);
}

if (bounding)
Expand Down Expand Up @@ -443,7 +443,6 @@ class DStyledItemDelegatePrivate : public DCORE_NAMESPACE::DObjectPrivate
for (int i = 0; i < list.count(); ++i) {
DViewItemAction *action = visiable_actionList.at(i);
const QRect &rect = list.at(i).translated(origin);

drawAction(pa, option, rect, action, spacing);

if (action->isClickable()) {
Expand Down

0 comments on commit 94be06f

Please sign in to comment.