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); + } } /** * 鼠标点击窗口外部事件