From 1b307497a2450bbefb979472de873b507bdc2e5e Mon Sep 17 00:00:00 2001 From: lixueman Date: Wed, 12 Oct 2022 11:03:51 +0800 Subject: [PATCH] =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E9=BB=98=E8=AE=A4=E7=AA=97?= =?UTF-8?q?=E5=8F=A3=E9=98=B4=E5=BD=B1=E6=95=88=E6=9E=9C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/UserInterface/Widget/main_view_widget.cpp | 15 ++---------- src/UserInterface/mainwindow.cpp | 24 +++++++++---------- 2 files changed, 13 insertions(+), 26 deletions(-) diff --git a/src/UserInterface/Widget/main_view_widget.cpp b/src/UserInterface/Widget/main_view_widget.cpp index c459745..c53fc53 100755 --- a/src/UserInterface/Widget/main_view_widget.cpp +++ b/src/UserInterface/Widget/main_view_widget.cpp @@ -54,23 +54,12 @@ void MainViewWidget::styleChangeSlot(const QString &style) void MainViewWidget::paintEvent(QPaintEvent *event) { -// double transparency = getTransparency(); - QRect rect = this->rect(); + QRect rect = this->rect().adjusted(5, 5, 0, -5); QPainterPath path; QPainter painter(this); + path.addRoundedRect(rect, 10, 10); painter.setRenderHint(QPainter::Antialiasing); // 反锯齿; painter.setPen(Qt::transparent); - qreal radius = 10; - path.moveTo(rect.topRight() - QPointF(radius, 0)); - path.lineTo(rect.topLeft() + QPointF(radius, 0)); - path.quadTo(rect.topLeft(), rect.topLeft() + QPointF(0, radius)); - path.lineTo(rect.bottomLeft() + QPointF(0, -radius)); - path.quadTo(rect.bottomLeft(), rect.bottomLeft() + QPointF(radius, 0)); - path.lineTo(rect.bottomRight() - QPointF(radius, 0)); - path.quadTo(rect.bottomRight(), rect.bottomRight() + QPointF(0, -radius)); - path.lineTo(rect.topRight() + QPointF(0, radius)); - path.quadTo(rect.topRight(), rect.topRight() + QPointF(-radius, -0)); - painter.setPen(Qt::transparent); painter.setOpacity(0.58); painter.fillPath(path, m_backColor); QWidget::paintEvent(event); diff --git a/src/UserInterface/mainwindow.cpp b/src/UserInterface/mainwindow.cpp index 53451fd..bd977a5 100755 --- a/src/UserInterface/mainwindow.cpp +++ b/src/UserInterface/mainwindow.cpp @@ -674,28 +674,26 @@ void MainWindow::paintEvent(QPaintEvent *event) if ( transparency == 1) { curColor.setAlpha(255); } - QRect rect = this->rect(); + QRect rect = this->rect().adjusted(5, 5, -5, -5); QPainterPath path; - // rect.setTopLeft(QPoint(rect.x()+320,rect.y())); QPainter painter(this); painter.setRenderHint(QPainter::Antialiasing); // 反锯齿; + painter.save(); painter.setPen(Qt::transparent); - qreal radius = 10; - path.moveTo(rect.topRight() - QPointF(radius, 0)); - path.lineTo(rect.topLeft() + QPointF(radius, 0)); - path.quadTo(rect.topLeft(), rect.topLeft() + QPointF(0, radius)); - path.lineTo(rect.bottomLeft() + QPointF(0, -radius)); - path.quadTo(rect.bottomLeft(), rect.bottomLeft() + QPointF(radius, 0)); - path.lineTo(rect.bottomRight() - QPointF(radius, 0)); - path.quadTo(rect.bottomRight(), rect.bottomRight() + QPointF(0, -radius)); - path.lineTo(rect.topRight() + QPointF(0, radius)); - path.quadTo(rect.topRight(), rect.topRight() + QPointF(-radius, -0)); + path.addRoundedRect(rect, 10, 10); painter.setBrush(curColor); painter.setPen(Qt::transparent); painter.setOpacity(transparency); painter.drawPath(path); KWindowEffects::enableBlurBehind(this->winId(), true, QRegion(path.toFillPolygon().toPolygon())); - QMainWindow::paintEvent(event); + QColor color = Qt::black; + for (int i = 0; i < 6; i++) { + rect = this->rect().adjusted(i, i, - i, - i); + color.setAlpha(i * 6); + painter.setBrush(Qt::NoBrush); + painter.setPen(QPen(color, 1)); + painter.drawRoundedRect(rect, 10, 10); + } } /** * 鼠标点击窗口外部事件