From 78b653c46dd9c5c555557ed88a37a60a113c9ad7 Mon Sep 17 00:00:00 2001 From: kangshuning Date: Tue, 30 Nov 2021 18:14:03 +0800 Subject: [PATCH] bug#93787 --- src/frontend/mainwindow.cpp | 13 ++++++++++++- src/frontend/mainwindow.h | 1 + src/frontend/tab-pages/tabpage.h | 2 +- 3 files changed, 14 insertions(+), 2 deletions(-) diff --git a/src/frontend/mainwindow.cpp b/src/frontend/mainwindow.cpp index 35d93700..0fc8e72e 100644 --- a/src/frontend/mainwindow.cpp +++ b/src/frontend/mainwindow.cpp @@ -120,7 +120,7 @@ void MainWindow::initWindowProperties() this->setFixedSize(MAINWINDOW_WIDTH, MAINWINDOW_HEIGHT); // //绘制毛玻璃特效 // this->setStyleSheet("background:transparent"); //透明 -// this->setAttribute(Qt::WA_TranslucentBackground, true); //半透明 +// this->setAttribute(Qt::WA_TranslucentBackground, true); //透明 this->setWindowOpacity(0.8); QPainterPath path; @@ -129,6 +129,15 @@ void MainWindow::initWindowProperties() KWindowEffects::enableBlurBehind(this->winId(), true, QRegion(path.toFillPolygon().toPolygon())); //背景模糊 } +void MainWindow::paintEvent(QPaintEvent *event) +{ + QPainter painter(this); + painter.setRenderHint(QPainter::Antialiasing); // 反锯齿; + painter.setPen(Qt::transparent); + auto rect = this->rect(); + painter.drawRoundedRect(rect, 6, 6); //窗口圆角 +} + /** * @brief MainWindow::initUI 初始化窗口内控件 */ @@ -137,6 +146,7 @@ void MainWindow::initUI() m_centralWidget = new QTabWidget(this); this->setCentralWidget(m_centralWidget); m_centralWidget->tabBar()->setFixedWidth(this->width()); + m_centralWidget->tabBar()->setStyleSheet("QTabBar::tab{min-height:40px}"); m_lanWidget = new LanPage(m_centralWidget); m_wlanWidget = new WlanPage(m_centralWidget); connect(this, &MainWindow::mainWindowVisibleChanged, m_wlanWidget, &WlanPage::onMainWindowVisibleChanged); @@ -155,6 +165,7 @@ void MainWindow::initUI() m_tabBarLayout->addWidget(m_wlanLabel); m_centralWidget->tabBar()->setLayout(m_tabBarLayout); connect(m_centralWidget, &QTabWidget::currentChanged, m_wlanWidget, &WlanPage::onWlanPageVisibleChanged); +// m_centralWidget->hide(); } /** diff --git a/src/frontend/mainwindow.h b/src/frontend/mainwindow.h index 8010dcea..ec0b6443 100644 --- a/src/frontend/mainwindow.h +++ b/src/frontend/mainwindow.h @@ -95,6 +95,7 @@ public slots: protected: void keyPressEvent(QKeyEvent *event); bool eventFilter(QObject *watched, QEvent *event) override; + void paintEvent(QPaintEvent *event); private: void firstlyStart(); //一级启动 diff --git a/src/frontend/tab-pages/tabpage.h b/src/frontend/tab-pages/tabpage.h index 5639355f..4782ede0 100644 --- a/src/frontend/tab-pages/tabpage.h +++ b/src/frontend/tab-pages/tabpage.h @@ -17,7 +17,7 @@ #define MAIN_LAYOUT_MARGINS 0,0,0,0 #define MAIN_LAYOUT_SPACING 0 -#define TITLE_FRAME_HEIGHT 52 +#define TITLE_FRAME_HEIGHT 50 //TabWidget的tab和widget有间隙,和设计稿看起来一致就不能设为设计稿里的高度 #define TITLE_LAYOUT_MARGINS 24,0,24,0 #define DEVICE_LAYOUT_MARGINS 24,0,24,8 #define DEVICE_COMBOBOX_WIDTH 150