Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

sync: from linuxdeepin/dtkwidget #34

Merged
merged 1 commit into from
Apr 1, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading