From e8e0f3c96f23d34321da2e54b1efba04897a2594 Mon Sep 17 00:00:00 2001 From: tsic404 Date: Wed, 31 Jan 2024 14:43:32 +0800 Subject: [PATCH] chore: adjust dock ui 1. adjust dock window space to 10 2. make traymainwindow contentsMagins to fixed value 3. make trycontrolpanel background color alpha 4. remove space between fullscreen and dock 5. set border for quick panel items 6. adjust standitem icon and text space 7. adjust sliderContainer icon background color log: as title --- frame/util/multiscreenworker.cpp | 2 +- frame/util/multiscreenworker.h | 2 +- frame/window/mainpanelcontrol.cpp | 2 +- frame/window/mainwindowbase.cpp | 8 ++--- frame/window/traymanagerwindow.cpp | 9 +++-- frame/window/windowmanager.cpp | 2 +- plugins/pluginmanager/quicksettingitem.cpp | 18 +++++++--- plugins/pluginmanager/standardquickitem.cpp | 3 +- widgets/slidercontainer.cpp | 40 +++++++++++++++++---- 9 files changed, 61 insertions(+), 25 deletions(-) diff --git a/frame/util/multiscreenworker.cpp b/frame/util/multiscreenworker.cpp index 37bf8fbfe..6cfeef6aa 100644 --- a/frame/util/multiscreenworker.cpp +++ b/frame/util/multiscreenworker.cpp @@ -422,7 +422,7 @@ void MultiScreenWorker::onRequestUpdateRegionMonitor() } // 触屏监控高度固定调整为最大任务栏高度100+任务栏与屏幕边缘间距 - const int monitHeight = 100 + WINDOWMARGIN; + const int monitHeight = 100 + WINDOWMARGIN * qApp->devicePixelRatio(); // 任务栏触屏唤起区域 m_touchRectList.clear(); diff --git a/frame/util/multiscreenworker.h b/frame/util/multiscreenworker.h index 5d85a3f1e..2cae2e78e 100644 --- a/frame/util/multiscreenworker.h +++ b/frame/util/multiscreenworker.h @@ -21,7 +21,7 @@ #include #include -#define WINDOWMARGIN ((m_displayMode == Dock::Efficient) ? 0 : 10) +#define WINDOWMARGIN ((m_displayMode == Dock::Efficient) ? 0 : 5) #define ANIMATIONTIME 300 #define FREE_POINT(p) if (p) {\ delete p;\ diff --git a/frame/window/mainpanelcontrol.cpp b/frame/window/mainpanelcontrol.cpp index b265d9afa..3fd18eccc 100644 --- a/frame/window/mainpanelcontrol.cpp +++ b/frame/window/mainpanelcontrol.cpp @@ -1097,7 +1097,7 @@ int MainPanelControl::trayAreaSize(qreal ratio) const length += (m_position == Dock::Position::Top || m_position == Dock::Position::Bottom ? topWindow->width() * ratio : topWindow->height() * ratio); } - length += topWindow->dockSpace() * ratio; + length += topWindow->dockSpace(); } return length; diff --git a/frame/window/mainwindowbase.cpp b/frame/window/mainwindowbase.cpp index 2db7c5b3b..d6f2ac236 100644 --- a/frame/window/mainwindowbase.cpp +++ b/frame/window/mainwindowbase.cpp @@ -431,9 +431,9 @@ QRect MainWindowBase::getDockGeometry(QScreen *screen, const Dock::Position &pos } int y = 0; if (pos == Dock::Position::Top) - y = (screenRect.y() + static_cast(margin / ratio)); + y = (screenRect.y() + static_cast(margin)); else - y = (screenRect.y() + static_cast(screenRect.height() / ratio - margin / ratio)) - dockSize; + y = (screenRect.y() + static_cast(screenRect.height() / ratio - margin)) - dockSize; rect.setX(x); rect.setY(y); rect.setWidth(width); @@ -451,9 +451,9 @@ QRect MainWindowBase::getDockGeometry(QScreen *screen, const Dock::Position &pos } int x = 0; if (pos == Dock::Position::Left) - x = screenRect.x() + static_cast(margin / ratio); + x = screenRect.x() + static_cast(margin); else - x = screenRect.x() + static_cast(screenRect.width() /ratio - margin / ratio) - dockSize; + x = screenRect.x() + static_cast(screenRect.width() /ratio - margin) - dockSize; int y = screenRect.y() + static_cast(((screenRect.height() / ratio) - totalSize) / 2); // 计算y坐标 diff --git a/frame/window/traymanagerwindow.cpp b/frame/window/traymanagerwindow.cpp index 7e547b031..53a0812ea 100644 --- a/frame/window/traymanagerwindow.cpp +++ b/frame/window/traymanagerwindow.cpp @@ -393,9 +393,8 @@ void TrayManagerWindow::resetChildWidgetSize() int dateTimeHeight = m_appPluginDatetimeWidget->height() - - m.top() - m.bottom() - trayHeight; m_dateTimeWidget->setFixedSize(dateTimeWidth, dateTimeHeight); m_systemPluginWidget->setFixedSize(m_systemPluginWidget->suitableSize()); - int contentSpace = qMin(MAXDIFF, qMax(((Utils::isDraging() ? height() : (int)m_windowFashionSize) - MINHIGHT), 0)) + MINSPACE; - m_mainLayout->setContentsMargins(contentSpace, contentSpace, contentSpace, contentSpace); - m_mainLayout->setSpacing(contentSpace); + m_mainLayout->setContentsMargins(SINGLEROWSPACE, SINGLEROWSPACE, SINGLEROWSPACE, SINGLEROWSPACE); + m_mainLayout->setSpacing(SINGLEROWSPACE); // 调整插件和日期窗体的位置显示,这里没有用到布局,是因为在调整任务栏位置的时候, // 随着布局方向的改变,显示有很大的问题 @@ -537,8 +536,8 @@ void TrayManagerWindow::paintEvent(QPaintEvent *event) painter.save(); painter.setRenderHint(QPainter::Antialiasing); painter.setClipPath(path); - painter.fillRect(rect().adjusted(1, 1, -1, -1), maskColor(102)); - painter.setPen(maskColor(110)); + painter.fillRect(rect().adjusted(1, 1, -1, -1), maskColor(255 * 0.1)); + painter.setPen(maskColor(255 * 0.15)); painter.drawPath(path); painter.restore(); diff --git a/frame/window/windowmanager.cpp b/frame/window/windowmanager.cpp index c247a1c37..bd3c4bc82 100644 --- a/frame/window/windowmanager.cpp +++ b/frame/window/windowmanager.cpp @@ -816,7 +816,7 @@ void WindowManager::onRequestNotifyWindowManager() } XcbMisc::instance()->set_strut_partial(static_cast(mainWindow->winId()), orientation, - static_cast(strut + WINDOWMARGIN * ratio), // 设置窗口与屏幕边缘距离,需要乘缩放 + static_cast(strut), // 设置窗口与屏幕边缘距离,需要乘缩放 static_cast(strutStart), // 设置任务栏起点坐标(上下为x,左右为y) static_cast(strutEnd)); // 设置任务栏终点坐标(上下为x,左右为y) } diff --git a/plugins/pluginmanager/quicksettingitem.cpp b/plugins/pluginmanager/quicksettingitem.cpp index 36f3a957b..d737d1995 100644 --- a/plugins/pluginmanager/quicksettingitem.cpp +++ b/plugins/pluginmanager/quicksettingitem.cpp @@ -93,12 +93,22 @@ void QuickSettingItem::paintEvent(QPaintEvent *e) painter.setClipPath(path); // 绘制背景色 QColor backColor(Qt::white); - if (DGuiApplicationHelper::instance()->themeType() == DGuiApplicationHelper::ColorType::DarkType) { - backColor = Qt::black; - } - backColor.setAlphaF(0.5); + backColor.setAlphaF(0.1); + DPalette dpa = DPaletteHelper::instance()->palette(this); painter.fillRect(rect(), backColor); + + QColor borderColor(Qt::black); + borderColor.setAlphaF(0.2); + if (DGuiApplicationHelper::instance()->themeType() == DGuiApplicationHelper::DarkType) { + borderColor = QColor(Qt::white); + borderColor.setAlphaF(0.15); + } + + painter.save(); + painter.setPen(borderColor); + painter.drawRoundedRect(rect(), RADIUS, RADIUS); + painter.restore(); } QColor QuickSettingItem::foregroundColor() const diff --git a/plugins/pluginmanager/standardquickitem.cpp b/plugins/pluginmanager/standardquickitem.cpp index 233fc3e84..9614cea24 100644 --- a/plugins/pluginmanager/standardquickitem.cpp +++ b/plugins/pluginmanager/standardquickitem.cpp @@ -100,6 +100,7 @@ QWidget *StandardQuickItem::iconWidget(QWidget *parent) layout->setAlignment(Qt::AlignVCenter); layout->setContentsMargins(0, 0, 0, 0); layout->setSpacing(0); + layout->addSpacing(6); QLabel *imageLabel = new QLabel(widget); imageLabel->setObjectName("imageLabel"); imageLabel->setFixedHeight(ICONHEIGHT); @@ -113,7 +114,7 @@ QWidget *StandardQuickItem::iconWidget(QWidget *parent) labelText->setFixedWidth(70); updatePluginName(labelText); layout->addWidget(imageLabel); - layout->addSpacing(7); + layout->addSpacing(4); layout->addWidget(labelText); } diff --git a/widgets/slidercontainer.cpp b/widgets/slidercontainer.cpp index 44e114281..6142e95c8 100644 --- a/widgets/slidercontainer.cpp +++ b/widgets/slidercontainer.cpp @@ -24,6 +24,7 @@ public: : QWidget(parent) , m_iconSize(QSize(24, 24)) , m_shadowSize(QSize()) + , m_isEnter(false) {} void updateData(const QIcon &icon, const QSize &iconSize, const QSize &shadowSize) @@ -40,6 +41,20 @@ public: update(); } + void enterEvent(QEvent *event) override + { + m_isEnter = true; + QWidget::enterEvent(event); + update(); + } + + void leaveEvent(QEvent *event) override + { + m_isEnter = false; + QWidget::leaveEvent(event); + update(); + } + protected: void paintEvent(QPaintEvent *e) override; @@ -47,6 +62,7 @@ private: QIcon m_icon; QSize m_iconSize; QSize m_shadowSize; + bool m_isEnter; }; void SliderIconWidget::paintEvent(QPaintEvent *e) @@ -60,8 +76,12 @@ void SliderIconWidget::paintEvent(QPaintEvent *e) // 绘制圆形背景 painter.setPen(Qt::NoPen); // 获取阴影部分背景颜色 - DPalette dpa = DPaletteHelper::instance()->palette(this); - painter.setBrush(dpa.brush(DPalette::ColorRole::Midlight)); + QColor backColor = (DGuiApplicationHelper::instance()->themeType() == DGuiApplicationHelper::ColorType::LightType ? Qt::black : Qt::white); + if (DGuiApplicationHelper::instance()->themeType() == DGuiApplicationHelper::ColorType::LightType) + backColor.setAlphaF(m_isEnter ? 0.2 : 0.1); + else + backColor.setAlphaF(m_isEnter ? 0.1 : 0.2); + painter.setBrush(backColor); int x = (rect().width() - m_shadowSize.width() ) / 2; int y = (rect().height() - m_shadowSize.height() ) / 2; painter.drawEllipse(QRect(x, y, m_shadowSize.width(), m_shadowSize.height())); @@ -270,23 +290,29 @@ void SliderProxyStyle::drawRoundSlider(QPainter *painter, QRect rectGroove, QRec QColor color = wigdet->isEnabled() ? (DGuiApplicationHelper::DarkType == DGuiApplicationHelper::instance()->themeType() ? Qt::white : Qt::black) : Qt::gray; // 此处中绘制圆形滑动条,需要绘制圆角,圆角大小为其高度的一半 int radius = rectGroove.height() / 2; - + // 此处绘制滑条的全长 - QBrush allBrush(QColor(190,190,190)); + QColor allBrush = (DGuiApplicationHelper::instance()->themeType() == DGuiApplicationHelper::ColorType::LightType ? Qt::black : Qt::white); + allBrush.setAlphaF( 0.15); + QPainterPath allPathGroove; allPathGroove.addRoundedRect(rectGroove, radius, radius); painter->fillPath(allPathGroove, allBrush); // 已经滑动过的区域 - QBrush brush(color); + if (DGuiApplicationHelper::instance()->themeType() == DGuiApplicationHelper::ColorType::DarkType) { + color.setAlphaF(0.6); + } + QPainterPath pathGroove; int handleSize = qMin(rectHandle.width(), rectHandle.height()); rectGroove.setWidth(rectHandle.x() + (rectHandle.width() - handleSize) / 2); pathGroove.addRoundedRect(rectGroove, radius, radius); - painter->fillPath(pathGroove, brush); + painter->fillPath(pathGroove, color); // 绘制滑块,因为滑块是正圆形,而它本来的区域是一个长方形区域,因此,需要计算当前 // 区域的正中心区域,将其作为一个正方形区域来绘制圆形滑块 + color.setAlphaF(1.0); int x = rectHandle.x() + (rectHandle.width() - handleSize) / 2; int y = rectHandle.y() + (rectHandle.height() - handleSize) / 2; rectHandle.setX(x); @@ -296,5 +322,5 @@ void SliderProxyStyle::drawRoundSlider(QPainter *painter, QRect rectGroove, QRec QPainterPath pathHandle; pathHandle.addEllipse(rectHandle); - painter->fillPath(pathHandle, brush); + painter->fillPath(pathHandle, color); }