forked from linuxdeepin/dde-control-center
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
使用新的账户头像资源,支持用户头像个性化配置 Log: 实现控制中心个性化头像定制功能 Resolve: linuxdeepin/developer-center#3796 Influence: 控制中心账户头像设置
- Loading branch information
Showing
18 changed files
with
1,864 additions
and
553 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
// SPDX-FileCopyrightText: 2018 - 2023 UnionTech Software Technology Co., Ltd. | ||
// | ||
// SPDX-License-Identifier: GPL-3.0-or-later | ||
|
||
#include "avatarcropbox.h" | ||
|
||
#include <QPainter> | ||
|
||
#define CropBoxSize 120 | ||
|
||
using namespace DCC_NAMESPACE; | ||
|
||
AvatarCropBox::AvatarCropBox(QWidget *parent) | ||
: QWidget(parent) | ||
, m_backgroundColor(parent->palette().color(QPalette::Window)) | ||
{ | ||
setFixedSize(190, 190); | ||
} | ||
|
||
AvatarCropBox::~AvatarCropBox() { } | ||
|
||
void AvatarCropBox::setBackgroundColor(QColor color) | ||
{ | ||
m_backgroundColor = color; | ||
|
||
repaint(); | ||
} | ||
|
||
void AvatarCropBox::paintEvent(QPaintEvent *event) | ||
{ | ||
Q_UNUSED(event); | ||
|
||
QPainter p(this); | ||
p.setRenderHint(QPainter::Antialiasing); | ||
|
||
auto rect = parentWidget()->rect(); | ||
|
||
QPainterPath border, cropBox; | ||
|
||
border.setFillRule(Qt::WindingFill); | ||
border.addRect(rect); | ||
|
||
cropBox.setFillRule(Qt::WindingFill); | ||
auto adjustSize = (rect.width() - CropBoxSize) / 2; | ||
cropBox.addRoundedRect(rect.adjusted(adjustSize, adjustSize, -adjustSize, -adjustSize), 10, 10); | ||
|
||
QPainterPath endPath = border.subtracted(cropBox); | ||
p.fillPath(endPath, m_backgroundColor); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
// SPDX-FileCopyrightText: 2018 - 2023 UnionTech Software Technology Co., Ltd. | ||
// | ||
// SPDX-License-Identifier: GPL-3.0-or-later | ||
#pragma once | ||
|
||
#include "interface/namespace.h" | ||
|
||
#include <QColor> | ||
#include <QPainterPath> | ||
#include <QWidget> | ||
|
||
namespace DCC_NAMESPACE { | ||
|
||
class AvatarCropBox : public QWidget | ||
{ | ||
Q_OBJECT | ||
public: | ||
AvatarCropBox(QWidget *parent = nullptr); | ||
~AvatarCropBox(); | ||
|
||
void setBackgroundColor(QColor color); | ||
|
||
protected: | ||
void paintEvent(QPaintEvent *event) override; | ||
|
||
private: | ||
QColor m_backgroundColor; | ||
}; | ||
|
||
} // namespace DCC_NAMESPACE |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.